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

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

本文整理了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

  1. public long getPos() throws IOException {
  2. if (raf != null) {
  3. return raf.getFilePointer();
  4. } else {
  5. return dataPos;
  6. }
  7. }

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

  1. public long getPos() throws IOException {
  2. if (raf != null) {
  3. return raf.getFilePointer();
  4. } else {
  5. return dataPos;
  6. }
  7. }

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

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

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

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

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

  1. public long skipBytes(long n) throws IOException {
  2. seek(getFilePointer() + n);
  3. return n;
  4. }

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

  1. public long skipBytes(long n) throws IOException {
  2. seek(getFilePointer() + n);
  3. return n;
  4. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public Grib1SectionBinaryData(RandomAccessFile raf) throws IOException {
  2. startingPosition = raf.getFilePointer();
  3. // octets 1-3 (Length of section)
  4. length = GribNumbers.uint3(raf);
  5. //if (length < 0)
  6. // throw new IllegalStateException("GRIB record has bad length, pos = " + startingPosition);
  7. raf.seek(startingPosition + length);
  8. }

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

  1. public Grib2SectionData(RandomAccessFile raf) throws IOException {
  2. startingPosition = raf.getFilePointer();
  3. // octets 1-4 (Length of section)
  4. msgLength = GribNumbers.int4(raf);
  5. // octet 5
  6. int section = raf.read();
  7. if (section != 7)
  8. throw new IllegalStateException("Not a Grib2SectionData (section 7)");
  9. // skip to end of the data section
  10. raf.seek(startingPosition + msgLength);
  11. }

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

  1. public Grib2SectionBitMap(RandomAccessFile raf) throws IOException {
  2. startingPosition = raf.getFilePointer();
  3. // octets 1-4 (Length of section)
  4. int length = GribNumbers.int4(raf);
  5. // octet 5
  6. int section = raf.read();
  7. if (section != 6)
  8. throw new IllegalArgumentException("Not a GRIB-2 Bitmap section");
  9. // octet 6
  10. bitMapIndicator = raf.read();
  11. raf.seek(startingPosition + length);
  12. }

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

  1. void read() throws IOException {
  2. if (debugPos) debugOut.println(" *MessageAttributeInfo start pos= " + raf.getFilePointer());
  3. byte version = raf.readByte();
  4. byte flags = raf.readByte();
  5. if ((flags & 1) != 0)
  6. maxCreationIndex = raf.readShort();
  7. fractalHeapAddress = readOffset();
  8. v2BtreeAddress = readOffset();
  9. if ((flags & 2) != 0)
  10. v2BtreeAddressCreationOrder = readOffset();
  11. if (debug1) debugOut.println(" MessageAttributeInfo version= " + version + " flags = " + flags + this);
  12. }
  13. }

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

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

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

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

相关文章