ucar.unidata.io.RandomAccessFile.getFilePointer()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中ucar.unidata.io.RandomAccessFile.getFilePointer方法的一些代码示例,展示了RandomAccessFile.getFilePointer的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.getFilePointer方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:getFilePointer

RandomAccessFile.getFilePointer介绍

[英]Returns the current position in the file, where the next read or write will occur.
[中]返回文件中的当前位置,即下一次读取或写入的位置。

代码示例

代码示例来源:origin: edu.ucar/cdm

public long getPos() throws IOException {
 if (raf != null) {
  return raf.getFilePointer();
 } else {
  return dataPos;
 }
}

代码示例来源:origin: Unidata/thredds

public long getPos() throws IOException {
 if (raf != null) {
  return raf.getFilePointer();
 } else {
  return dataPos;
 }
}

代码示例来源:origin: edu.ucar/netcdf

@Override
public boolean hasNext() throws IOException {
 if (!exists) return false;
 if (timeSeriesRaf == null) init();
 return (timeSeriesRaf.getFilePointer() < totalBytes); // && (recno < 10);   LOOK not perfect, eg trailing blanks
}

代码示例来源:origin: edu.ucar/cdm

@Override
public boolean hasNext() throws IOException {
 if (!exists) return false;
 if (timeSeriesRaf == null) init();
 return (timeSeriesRaf.getFilePointer() < totalBytes); // && (recno < 10);   LOOK not perfect, eg trailing blanks
}

代码示例来源:origin: edu.ucar/netcdf

public long skipBytes(long n) throws IOException {
 seek(getFilePointer() + n);
 return n;
}

代码示例来源:origin: Unidata/thredds

public long skipBytes(long n) throws IOException {
 seek(getFilePointer() + n);
 return n;
}

代码示例来源:origin: edu.ucar/netcdf

private boolean endRecord(RandomAccessFile raf) throws IOException {
 if (showSkip) System.out.print(" endRecord start at " + raf.getFilePointer());
 int skipped = 0;
 String endRecord = new String(raf.readBytes(10));
 while (endRecord.equals("END RECORD")) {
  endRecord = new String(raf.readBytes(10));
  skipped++;
 }
 if (showSkip) System.out.println(" last 10 chars= " + endRecord + " skipped= " + skipped);
 return true;
}

代码示例来源:origin: edu.ucar/cdm

private boolean endRecord(RandomAccessFile raf) throws IOException {
 if (showSkip) System.out.print(" endRecord start at " + raf.getFilePointer());
 int skipped = 0;
 String endRecord = raf.readString(10); // new String(raf.readBytes(10), CDM.utf8Charset);
 while (endRecord.equals("END RECORD")) {
  endRecord = raf.readString(10); // new String(raf.readBytes(10));
  skipped++;
 }
 if (showSkip) System.out.println(" last 10 chars= " + endRecord + " skipped= " + skipped);
 return true;
}

代码示例来源:origin: Unidata/thredds

private boolean endRecord(RandomAccessFile raf) throws IOException {
 if (showSkip) System.out.print(" endRecord start at " + raf.getFilePointer());
 int skipped = 0;
 String endRecord = raf.readString(10); // new String(raf.readBytes(10), CDM.utf8Charset);
 while (endRecord.equals("END RECORD")) {
  endRecord = raf.readString(10); // new String(raf.readBytes(10));
  skipped++;
 }
 if (showSkip) System.out.println(" last 10 chars= " + endRecord + " skipped= " + skipped);
 return true;
}

代码示例来源:origin: edu.ucar/cdm

private void skip(int nbytes) throws IOException {
 int pad = padding(nbytes);
 if (pad > 0)
  raf.seek(raf.getFilePointer() + pad);
}

代码示例来源:origin: Unidata/thredds

/**
 * Constructs a <tt>BufrIndicatorSection</tt> object from a raf.
 *
 * @param raf RandomAccessFile with IndicatorSection content
 * @throws IOException on read error
 */
public BufrIndicatorSection(RandomAccessFile raf) throws IOException {
 this.startPos = raf.getFilePointer() - 4; // start of BUFR message, including "BUFR"
 bufrLength = BufrNumbers.uint3(raf);
 edition = raf.read();
}

代码示例来源:origin: Unidata/thredds

public Grib1SectionBitMap(RandomAccessFile raf) throws IOException {
 startingPosition = raf.getFilePointer();
 // octets 1-3 (Length of section)
 int length = GribNumbers.int3(raf);
 raf.seek(startingPosition + length);
}

代码示例来源:origin: edu.ucar/bufr

/**
 * Constructs a <tt>BufrIndicatorSection</tt> object from a raf.
 *
 * @param raf RandomAccessFile with IndicatorSection content
 * @throws IOException on read error
 */
public BufrIndicatorSection(RandomAccessFile raf) throws IOException {
 this.startPos = raf.getFilePointer() - 4; // start of BUFR message, including "BUFR"
 bufrLength = BufrNumbers.uint3(raf);
 edition = raf.read();
 //length = 8;
}

代码示例来源:origin: Unidata/thredds

private void skip(int nbytes) throws IOException {
 int pad = padding(nbytes);
 if (pad > 0)
  raf.seek(raf.getFilePointer() + pad);
}

代码示例来源:origin: Unidata/thredds

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);
}

代码示例来源:origin: Unidata/thredds

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);
}

代码示例来源:origin: Unidata/thredds

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);
}

代码示例来源:origin: edu.ucar/cdm

void read() throws IOException {
  if (debugPos) debugOut.println("   *MessageAttributeInfo start pos= " + raf.getFilePointer());
  byte version = raf.readByte();
  byte flags = raf.readByte();
  if ((flags & 1) != 0)
   maxCreationIndex = raf.readShort();
  fractalHeapAddress = readOffset();
  v2BtreeAddress = readOffset();
  if ((flags & 2) != 0)
   v2BtreeAddressCreationOrder = readOffset();
  if (debug1) debugOut.println("   MessageAttributeInfo version= " + version + " flags = " + flags + this);
 }
}

代码示例来源:origin: edu.ucar/cdm

void dump(String head, long filePos, int nbytes, boolean count) throws IOException {
 long savePos = raf.getFilePointer();
 if (filePos >= 0) raf.seek(filePos);
 byte[] mess = new byte[nbytes];
 raf.readFully(mess);
 printBytes(head, mess, nbytes, false, debugOut);
 raf.seek(savePos);
}

代码示例来源:origin: edu.ucar/netcdf

void dump(String head, long filePos, int nbytes, boolean count) throws IOException {
 long savePos = raf.getFilePointer();
 if (filePos >= 0) raf.seek(filePos);
 byte[] mess = new byte[nbytes];
 raf.read(mess);
 printBytes(head, mess, nbytes, false, debugOut);
 raf.seek(savePos);
}

相关文章