当前位置: 首页>>代码示例>>Java>>正文


Java RandomAccessFile.getFilePointer方法代码示例

本文整理汇总了Java中ucar.unidata.io.RandomAccessFile.getFilePointer方法的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessFile.getFilePointer方法的具体用法?Java RandomAccessFile.getFilePointer怎么用?Java RandomAccessFile.getFilePointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ucar.unidata.io.RandomAccessFile的用法示例。


在下文中一共展示了RandomAccessFile.getFilePointer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Grib2SectionProductDefinition

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Product Definition section from raf.
*
* @param raf RandomAccessFile, with pointer at start of section
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib2SectionProductDefinition( RandomAccessFile raf) throws IOException {

  long startingPosition = raf.getFilePointer();

  // octets 1-4 (Length of GDS)
  int length = GribNumbers.int4(raf);

 // octet 5
  int section = raf.read();
  if (section != 4)
    throw new IllegalArgumentException("Not a GRIB-2 PDS section");

  // octets 8-9
  raf.skipBytes(2);
  templateNumber = GribNumbers.int2(raf);

  // read in whole GDS as byte[]
  rawData = new byte[length];
  raf.seek(startingPosition);
  raf.readFully(rawData);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:29,代码来源:Grib2SectionProductDefinition.java

示例2: Grib2SectionIndicator

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * Read Grib2SectionIndicator from raf.
 *
 * @param raf RandomAccessFile, with pointer at start (the "GRIB")
 * @throws java.io.IOException on I/O error
 * @throws IllegalArgumentException if not a GRIB-2 record
 */
public Grib2SectionIndicator(RandomAccessFile raf) throws IOException {
	startPos = raf.getFilePointer();
	byte[] b = new byte[4];
	raf.readFully(b);
	// 判断是不是GRIB
	for (int i = 0; i < b.length; i++) {
		if (b[i] != MAGIC[i])
			throw new IllegalArgumentException("Not a GRIB record");
	}

	raf.skipBytes(2);
	discipline = raf.read();
	int edition = raf.read();
	if (edition != 2)
		throw new IllegalArgumentException("Not a GRIB-2 record");

	messageLength = GribNumbers.int8(raf);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:26,代码来源:Grib2SectionIndicator.java

示例3: Grib2SectionDataRepresentation

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
public Grib2SectionDataRepresentation(RandomAccessFile raf) throws IOException {
  startingPosition = raf.getFilePointer();

  // octets 1-4 (Length of DRS)
  length = GribNumbers.int4(raf);
  if (length == 0)
    throw new IllegalArgumentException("Not a GRIB-2 Data representation section");

 // octet 5
  int section = raf.read();
  if (section != 5)
    throw new IllegalArgumentException("Not a GRIB-2 Data representation section");

  // octets 6-9 number of datapoints
  dataPoints = GribNumbers.int4(raf);

  // octet 10-11
  int dt = GribNumbers.uint2(raf);
  dataTemplate = (dt == 40000) ? 40 : dt; // ?? NCEP bug ??

  raf.seek(startingPosition+length);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:23,代码来源:Grib2SectionDataRepresentation.java

示例4: Grib2SectionGridDefinition

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * Read Grib Definition section from raf.
 *
 * @param raf RandomAccessFile, with pointer at start of section
 * @throws java.io.IOException on I/O error
 * @throws IllegalArgumentException if not a GRIB-2 record
 */
public Grib2SectionGridDefinition(RandomAccessFile raf) throws IOException {

  startingPosition = raf.getFilePointer();

  // octets 1-4 (Length of GDS)
  int length = GribNumbers.int4(raf);

 // octet 5
  int section = raf.read();  // This is section 3
  if (section != 3)
    throw new IllegalArgumentException("Not a GRIB-2 GDS section");

  // octets 13-14
  raf.skipBytes(7);
  templateNumber = GribNumbers.uint2(raf);

  // read in whole GDS as byte[]
  rawData = new byte[length];
  raf.seek(startingPosition);
  raf.readFully(rawData);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:29,代码来源:Grib2SectionGridDefinition.java

示例5: Grib1SectionGridDefinition

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * Read Grib Definition section from raf.
 *
 * @param raf RandomAccessFile, with pointer at start of section
 * @throws java.io.IOException      on I/O error
 * @throws IllegalArgumentException if not a GRIB-2 record
 */
public Grib1SectionGridDefinition(RandomAccessFile raf) throws IOException {

  startingPosition = raf.getFilePointer();

  // octets 1-3 (Length of GDS)
  int length = GribNumbers.int3(raf);

  // octet 6
  raf.skipBytes(2);
  gridTemplate = GribNumbers.uint(raf);

  // read in whole GDS as byte[]
  rawData = new byte[length];
  raf.seek(startingPosition);
  raf.readFully(rawData);

  predefinedGridDefinition = -1;
  predefinedGridDefinitionCenter = -1;
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:27,代码来源:Grib1SectionGridDefinition.java

示例6: Grib2SectionData

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
public Grib2SectionData(RandomAccessFile raf) throws IOException {
  startingPosition = raf.getFilePointer();

  // octets 1-4 (Length of section)
  msgLength = GribNumbers.int4(raf);

  // octet 5
  int section = raf.read();
  if (section != 7)
    throw new IllegalStateException("Not a Grib2SectionData (section 7)");

  // skip to end of the data section
  raf.seek(startingPosition + msgLength);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:15,代码来源:Grib2SectionData.java

示例7: Type50002

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
Type50002(RandomAccessFile raf) throws IOException {
	      // according to https://github.com/erdc-cm/grib_api/blob/master/definitions/grib2/template.5.50002.def
	      this.referenceValue = raf.readFloat();
	      this.binaryScaleFactor = GribNumbers.int2(raf);
	      this.decimalScaleFactor = GribNumbers.int2(raf);
	      this.numberOfBits = raf.read();
	      this.widthOfFirstOrderValues = raf.read();
	      this.p1 = GribNumbers.int4(raf);
	      this.p2 = GribNumbers.int4(raf);
	      this.widthOfWidth = raf.read();
	      this.widthOfLength = raf.read();
	      this.boustrophonic = raf.read();
	      this.orderOfSPD = raf.read();
	      this.widthOfSPD = raf.read();
	      this.spd = new int[orderOfSPD+1];
	      BitReader bitReader = new BitReader(raf, raf.getFilePointer());
	      for (int i = 0; i < orderOfSPD; i++) {
/*
 	    	  int myInt = raf.read();
	    	  System.out.println("spd["+i+"]="+myInt+" 0x"+Integer.toHexString(myInt)+" 0b"+Integer.toBinaryString(myInt)+" widthOfSPD="+widthOfSPD);
	    	  myInt = raf.read();
	    	  System.out.println("spd["+i+"]="+myInt+" 0x"+Integer.toHexString(myInt)+" 0b"+Integer.toBinaryString(myInt)+" widthOfSPD="+widthOfSPD);
/**/
		     this.spd[i] = (int) bitReader.bits2UInt(widthOfSPD);
	      }
	      this.spd[orderOfSPD] = (int) bitReader.bits2SInt(widthOfSPD);
	      this.lengthOfSection6 = GribNumbers.int4(raf);
	      this.section6 = raf.read();
	      this.bitMapIndicator = raf.read();
	      this.lengthOfSection7 = GribNumbers.int4(raf);
	      this.section7 = raf.read();
	    }
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:33,代码来源:Grib2Drs.java

示例8: Grib2SectionBitMap

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
public Grib2SectionBitMap(RandomAccessFile raf) throws IOException {
  startingPosition = raf.getFilePointer();

  // octets 1-4 (Length of section)
  int length = GribNumbers.int4(raf);

  // octet 5
  int section = raf.read();
  if (section != 6)
    throw new IllegalArgumentException("Not a GRIB-2 Bitmap section");

  // octet 6
  bitMapIndicator = raf.read();
  raf.seek(startingPosition + length);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:16,代码来源:Grib2SectionBitMap.java

示例9: findRecordByDrspos

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * tricky bit of business. recapture the entire record based on drs position.
 * for validation.
 * @param raf             from this RandomAccessFile
 * @param drsPos          Grib2SectionDataRepresentation starts here
 */
public static Grib2Record findRecordByDrspos(RandomAccessFile raf, long drsPos) throws IOException {
	long pos = Math.max(0, drsPos - (20 * 1000)); // go back 20K
	Grib2RecordScanner scan = new Grib2RecordScanner(raf, pos);
	while (scan.hasNext()) {
		ucar.nc2.grib.grib2.Grib2Record gr = scan.next();
		Grib2SectionDataRepresentation drs = gr.getDataRepresentationSection();
		if (drsPos == drs.getStartingPosition())
			return gr;
		if (raf.getFilePointer() > drsPos)
			break; // missed it.
	}
	return null;
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:20,代码来源:Grib2RecordScanner.java

示例10: Grib1SectionBitMap

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
public Grib1SectionBitMap(RandomAccessFile raf) throws IOException {
  startingPosition = raf.getFilePointer();

  // octets 1-3 (Length of section)
  int length = GribNumbers.int3(raf);

  raf.seek(startingPosition + length);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:9,代码来源:Grib1SectionBitMap.java

示例11: Grib1SectionIndicator

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * Read Grib2SectionIndicator from raf.
 *
 * @param raf RandomAccessFile, with pointer at start (the "GRIB")
 * @throws java.io.IOException on I/O error
 * @throws IllegalArgumentException if not a GRIB-2 record
 */
public Grib1SectionIndicator(RandomAccessFile raf) throws IOException {
  startPos = raf.getFilePointer();
  byte[] b = new byte[4];
  raf.readFully(b);
  for (int i = 0; i < b.length; i++)
    if (b[i] != MAGIC[i])
      throw new IllegalArgumentException("Not a GRIB record");

  messageLength = GribNumbers.uint3(raf);
  int edition = raf.read();
  if (edition != 1)
    throw new IllegalArgumentException("Not a GRIB-1 record");
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:21,代码来源:Grib1SectionIndicator.java

示例12: Grib1SectionBinaryData

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
public Grib1SectionBinaryData(RandomAccessFile raf) throws IOException {
  startingPosition = raf.getFilePointer();

  // octets 1-3 (Length of section)
  length = GribNumbers.uint3(raf);
  //if (length < 0)
  //  throw new IllegalStateException("GRIB record has bad length, pos = " + startingPosition);
  raf.seek(startingPosition + length);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:10,代码来源:Grib1SectionBinaryData.java

示例13: Grib2SectionIdentification

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
 * Read Grib2SectionIndicator from raf.
 *
 * @param raf RandomAccessFile, with pointer at start of indicator section
 * @throws java.io.IOException on I/O error
 * @throws IllegalArgumentException if not a GRIB-2 record
 */
public Grib2SectionIdentification(RandomAccessFile raf) throws IOException {
	long sectionEnd = raf.getFilePointer();

	// section 1 octet 1-4 (length of section)
	int length = GribNumbers.int4(raf);
	sectionEnd += length;

	int section = raf.read();
	if (section != 1)
		throw new IllegalArgumentException("Not a GRIB-2 Identification section");

	// Center octet 6-7
	center_id = GribNumbers.int2(raf);

	// subCenter octet 8-9
	subcenter_id = GribNumbers.int2(raf);

	// master table octet 10 (code table 1.0)
	master_table_version = raf.read();

	// local table octet 11 (code table 1.1)
	local_table_version = raf.read();

	// significanceOfRT octet 12 (code table 1.1)
	significanceOfRT = raf.read();

	// octets 13-19 (reference time of forecast)
	year = GribNumbers.int2(raf);
	month = raf.read();
	day = raf.read();
	hour = raf.read();
	minute = raf.read();
	second = raf.read();
	// refTime = CalendarDate.of(null, year, month, day, hour, minute, second);

	productionStatus = raf.read();
	processedDataType = raf.read();

	raf.seek(sectionEnd);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:48,代码来源:Grib2SectionIdentification.java

示例14: showOffset

import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
private void showOffset(String what, RandomAccessFile raf, int expectOffset, int expectDump)
        throws IOException {
    int offset = (int) (raf.getFilePointer() - this.startPos);
    System.out.printf("%s: filePos=%d, expectDump=%d, offset=%d expect=%d%n", what,
            raf.getFilePointer(), expectDump, offset, expectOffset);
}
 
开发者ID:0nirvana0,项目名称:grib2reader,代码行数:7,代码来源:Grib1DataReader.java


注:本文中的ucar.unidata.io.RandomAccessFile.getFilePointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。