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

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

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

RandomAccessFile.skipBytes介绍

[英]Skips exactly n bytes of input. This method blocks until all the bytes are skipped, the end of the stream is detected, or an exception is thrown.
[中]完全跳过n字节的输入。此方法会一直阻塞,直到跳过所有字节、检测到流结束或引发异常为止。

代码示例

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

  1. private float getDataBlockValue1(RandomAccessFile raf, short offset, int skip) throws IOException {
  2. long off = offset + message_offset + MESSAGE_HEADER_SIZE;
  3. raf.seek(off);
  4. raf.skipBytes(skip);
  5. return raf.readFloat();
  6. }

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

  1. private float getDataBlockValue1(RandomAccessFile raf, short offset, int skip) throws IOException {
  2. long off = offset + message_offset + MESSAGE_HEADER_SIZE;
  3. raf.seek(off);
  4. raf.skipBytes(skip);
  5. return raf.readFloat();
  6. }

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

  1. private short getDataBlockValue(RandomAccessFile raf, short offset, int skip) throws IOException {
  2. long off = offset + message_offset + MESSAGE_HEADER_SIZE;
  3. raf.seek(off);
  4. raf.skipBytes(skip);
  5. return raf.readShort();
  6. }

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

  1. private short getDataBlockValue(RandomAccessFile raf, short offset, int skip) throws IOException {
  2. long off = offset + message_offset + MESSAGE_HEADER_SIZE;
  3. raf.seek(off);
  4. raf.skipBytes(skip);
  5. return raf.readShort();
  6. }

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

  1. void read() throws IOException {
  2. version = raf.readByte();
  3. raf.skipBytes(3); // skip byte
  4. secs = raf.readInt();
  5. }

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

  1. void read() throws IOException {
  2. byte version = raf.readByte();
  3. byte nfilters = raf.readByte();
  4. if (version == 1) raf.skipBytes(6);
  5. filters = new Filter[nfilters];
  6. for (int i = 0; i < nfilters; i++)
  7. filters[i] = new Filter(version);
  8. if (debug1) debugOut.println(" MessageFilter version=" + version + this);
  9. }

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

  1. void read() throws IOException {
  2. byte version = raf.readByte();
  3. byte nfilters = raf.readByte();
  4. if (version == 1) raf.skipBytes(6);
  5. filters = new Filter[nfilters];
  6. for (int i = 0; i < nfilters; i++)
  7. filters[i] = new Filter(version);
  8. if (debug1) debugOut.println(" MessageFilter version=" + version + this);
  9. }

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

  1. static public boolean isValidFile(RandomAccessFile raf) throws IOException {
  2. raf.seek(0);
  3. if (!raf.searchForward(matcher, 8000)) return false; // must find "GRIB" in first 8k
  4. raf.skipBytes(4);
  5. // Read Section 0 Indicator Section to get Edition number
  6. Grib2IndicatorSection is = new Grib2IndicatorSection(raf); // section 0
  7. if (is.getGribEdition() != 1 && is.getGribEdition() != 2)
  8. return false;
  9. if (is.getGribLength() > raf.length())
  10. return false;
  11. return true;
  12. }

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

  1. Object readDoubleArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 8;
  3. double[] array = new double[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readDouble(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readFloatArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 4;
  3. float[] array = new float[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readFloat(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readFloatArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 4;
  3. float[] array = new float[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readFloat(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readFloatArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 4;
  3. float[] array = new float[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readFloat(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readIntArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 4;
  3. int[] array = new int[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readInt(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readDoubleArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 8;
  3. double[] array = new double[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readDouble(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. Object readByteArray2D(int offsetInRecord, int numElementsInRecord) throws IOException {
  2. byte[] array = new byte[header.getNumDataRecords() * numElementsInRecord];
  3. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  4. for (int i = 0; i < header.getNumDataRecords(); i++) {
  5. this.raf.readFully(array, i * numElementsInRecord, numElementsInRecord);
  6. this.raf.skipBytes(header.getRecordSizeInBytes() - numElementsInRecord);
  7. }
  8. return (array);
  9. }

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

  1. Object readByteArray2D(int offsetInRecord, int numElementsInRecord) throws IOException {
  2. byte[] array = new byte[header.getNumDataRecords() * numElementsInRecord];
  3. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  4. for (int i = 0; i < header.getNumDataRecords(); i++) {
  5. this.raf.read(array, i * numElementsInRecord, numElementsInRecord);
  6. this.raf.skipBytes(header.getRecordSizeInBytes() - numElementsInRecord);
  7. }
  8. return (array);
  9. }

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

  1. Object readIntArray1D(int offsetInRecord) throws IOException {
  2. int elementSizeInBytes = 4;
  3. int[] array = new int[header.getNumDataRecords()];
  4. this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
  5. for (int i = 0; i < header.getNumDataRecords(); i++) {
  6. this.raf.readInt(array, i, 1);
  7. this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes);
  8. }
  9. return (array);
  10. }

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. xdim = raf.readInt();
  4. ydim = raf.readInt();
  5. raf.skipBytes(2);
  6. nt_ref = raf.readShort();
  7. nelems = raf.readShort();
  8. interlace = raf.readShort();
  9. compress = raf.readShort();
  10. compress_ref = raf.readShort();
  11. }

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. xdim = raf.readInt();
  4. ydim = raf.readInt();
  5. raf.skipBytes(2);
  6. nt_ref = raf.readShort();
  7. nelems = raf.readShort();
  8. interlace = raf.readShort();
  9. compress = raf.readShort();
  10. compress_ref = raf.readShort();
  11. }

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

  1. protected void read() throws IOException {
  2. raf.seek(offset);
  3. xdim = raf.readInt();
  4. ydim = raf.readInt();
  5. raf.skipBytes(2);
  6. nt_ref = raf.readShort();
  7. nelems = raf.readShort();
  8. interlace = raf.readShort();
  9. compress = raf.readShort();
  10. compress_ref = raf.readShort();
  11. }

相关文章