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

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

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

RandomAccessFile.order介绍

[英]Change the current endian mode. Subsequent reads of short, int, float, double, long, char will use this. Does not currently affect writes. Default values is BIG_ENDIAN.
[中]更改当前的endian模式。随后读取short、int、float、double、long和char将使用此选项。目前不影响写入。默认值是BIG_ENDIAN。

代码示例

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

  1. public Grib2RecordScanner(RandomAccessFile raf) throws IOException {
  2. this.raf = raf;
  3. raf.seek(0);
  4. raf.order(RandomAccessFile.BIG_ENDIAN);
  5. lastPos = 0;
  6. if (debugRepeat) System.out.printf(" Grib2RecordScanner %s%n", raf.getLocation());
  7. }

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

  1. public Grib1RecordScanner(RandomAccessFile raf) throws IOException {
  2. this.raf = raf;
  3. raf.seek(0);
  4. raf.order(RandomAccessFile.BIG_ENDIAN);
  5. lastPos = 0;
  6. }

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

  1. public MessageScanner(RandomAccessFile raf, long startPos) throws IOException {
  2. startPos = (startPos < 30) ? 0 : startPos - 30; // look for the header
  3. this.raf = raf;
  4. raf.seek(startPos);
  5. raf.order(RandomAccessFile.BIG_ENDIAN);
  6. lastPos = startPos;
  7. }

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

  1. public MessageScanner(RandomAccessFile raf, long startPos, boolean useEmbeddedTables) throws IOException {
  2. startPos = (startPos < 30) ? 0 : startPos - 30; // look for the header
  3. this.raf = raf;
  4. lastPos = startPos;
  5. this.useEmbeddedTables = useEmbeddedTables;
  6. raf.seek(startPos);
  7. raf.order(RandomAccessFile.BIG_ENDIAN);
  8. }

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

  1. private Grib2RecordScanner(RandomAccessFile raf, long startFrom) throws IOException {
  2. this.raf = raf;
  3. raf.seek(startFrom);
  4. raf.order(RandomAccessFile.BIG_ENDIAN);
  5. lastPos = startFrom;
  6. }

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

  1. public void reacquire() throws IOException {
  2. raf = RandomAccessFile.acquire(location);
  3. this.raf.order(rafOrder);
  4. }

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

  1. /**
  2. * Check if this is a valid SIGMET-IRIS file for this IOServiceProvider.
  3. */
  4. public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) {
  5. try {
  6. raf.order(RandomAccessFile.LITTLE_ENDIAN);
  7. raf.seek(24);
  8. return (raf.readShort() == (short) 15);
  9. } catch (IOException ioe) {
  10. System.out.println("In isValidFile(): " + ioe.toString());
  11. return false;
  12. }
  13. }

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

  1. @Override
  2. public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException {
  3. // this is the first time we try to read the file - if there's a problem we get a IOException
  4. raf.seek(0);
  5. raf.order(ByteOrder.BIG_ENDIAN);
  6. int fileCode = raf.readInt();
  7. if (fileCode != MAGIC)
  8. return false;
  9. raf.seek(28);
  10. raf.order(ByteOrder.LITTLE_ENDIAN);
  11. int version = raf.readInt();
  12. if (version != VERSION)
  13. return false;
  14. return true;
  15. }

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

  1. @Override
  2. public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException {
  3. // this is the first time we try to read the file - if there's a problem we get a IOException
  4. raf.seek(0);
  5. raf.order(ByteOrder.BIG_ENDIAN);
  6. int fileCode = raf.readInt();
  7. if (fileCode != MAGIC)
  8. return false;
  9. raf.seek(28);
  10. raf.order(ByteOrder.LITTLE_ENDIAN);
  11. int version = raf.readInt();
  12. if (version != VERSION)
  13. return false;
  14. return true;
  15. }

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

  1. @Override
  2. public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException {
  3. // this is the first time we try to read the file - if there's a problem we get a IOException
  4. raf.seek(0);
  5. raf.order(ByteOrder.BIG_ENDIAN);
  6. int fileCode = raf.readInt();
  7. if (fileCode != MAGIC)
  8. return false;
  9. raf.seek(28);
  10. raf.order(ByteOrder.LITTLE_ENDIAN);
  11. int version = raf.readInt();
  12. if (version != VERSION)
  13. return false;
  14. return true;
  15. }

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

  1. private static void dump(String filename) throws IOException {
  2. System.out.printf("Dump %s%n", filename);
  3. RandomAccessFile raf = new RandomAccessFile(filename, "r");
  4. NetcdfFile ncfile = new MyNetcdfFile();
  5. // its a netcdf-3 file
  6. raf.order(RandomAccessFile.BIG_ENDIAN);
  7. N3header headerParser = new N3header();
  8. headerParser.read(raf, ncfile, new Formatter(System.out));
  9. raf.close();
  10. }

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

  1. private void readHeader() throws IOException {
  2. raf.seek(32);
  3. raf.order(ByteOrder.LITTLE_ENDIAN);
  4. int itype = raf.readInt();
  5. type = assignType(itype);
  6. bb = readBoundingBox();
  7. }

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

  1. private void readHeader() throws IOException {
  2. raf.seek(32);
  3. raf.order(ByteOrder.LITTLE_ENDIAN);
  4. int itype = raf.readInt();
  5. type = assignType(itype);
  6. bb = readBoundingBox();
  7. }

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

  1. private void readHeader() throws IOException {
  2. raf.seek(32);
  3. raf.order(ByteOrder.LITTLE_ENDIAN);
  4. int itype = raf.readInt();
  5. type = assignType(itype);
  6. bb = readBoundingBox();
  7. }

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

  1. HeapIdentifier(long address) throws IOException {
  2. // header information is in le byte order
  3. raf.order(RandomAccessFile.LITTLE_ENDIAN);
  4. raf.seek(address);
  5. nelems = raf.readInt();
  6. heapAddress = readOffset();
  7. index = raf.readInt();
  8. if (debugDetail)
  9. debugOut.println(" read HeapIdentifier address=" + address + this);
  10. if (debugHeap) dump("heapIdentifier", getFileOffset(address), 16, true);
  11. }

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

  1. HeapIdentifier(long address) throws IOException {
  2. // header information is in le byte order
  3. raf.order(RandomAccessFile.LITTLE_ENDIAN);
  4. raf.seek(address);
  5. nelems = raf.readInt();
  6. heapAddress = readOffset();
  7. index = raf.readInt();
  8. if (debugDetail)
  9. debugOut.println(" read HeapIdentifier address=" + address + this);
  10. if (debugHeap) dump("heapIdentifier", getFileOffset(address), 16, true);
  11. }

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

  1. HeapIdentifier(long address) throws IOException {
  2. // header information is in le byte order
  3. raf.order(RandomAccessFile.LITTLE_ENDIAN);
  4. raf.seek(address);
  5. nelems = raf.readInt();
  6. heapAddress = readOffset();
  7. index = raf.readInt();
  8. if (debugDetail) {
  9. log.debug(" read HeapIdentifier address=" + address + this);
  10. }
  11. if (debugHeap) dump("heapIdentifier", getFileOffset(address), 16, true);
  12. }

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

  1. public Array readData(Variable v2, Section wantSection) throws IOException, InvalidRangeException {
  2. // raf.seek(0);
  3. raf.order(RandomAccessFile.BIG_ENDIAN);
  4. int size = (int) wantSection.computeSize();
  5. short[] arr = new short[size];
  6. LayoutRegular indexer = new LayoutRegular(0, v2.getElementSize(), v2.getShape(), wantSection);
  7. while (indexer.hasNext()) {
  8. Layout.Chunk chunk = indexer.next();
  9. raf.seek(chunk.getSrcPos());
  10. raf.readShort(arr, (int) chunk.getDestElem(), chunk.getNelems()); // copy into primitive array
  11. }
  12. return Array.factory(v2.getDataType(), wantSection.getShape(), arr);
  13. }

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

  1. public Array readData(Variable v2, Section wantSection) throws IOException, InvalidRangeException {
  2. // raf.seek(0);
  3. raf.order(RandomAccessFile.BIG_ENDIAN);
  4. int size = (int) wantSection.computeSize();
  5. short[] arr = new short[size];
  6. LayoutRegular indexer = new LayoutRegular(0, v2.getElementSize(), v2.getShape(), wantSection);
  7. while (indexer.hasNext()) {
  8. Layout.Chunk chunk = indexer.next();
  9. raf.seek(chunk.getSrcPos());
  10. raf.readShort(arr, (int) chunk.getDestElem(), chunk.getNelems()); // copy into primitive array
  11. }
  12. return Array.factory(v2.getDataType().getPrimitiveClassType(), wantSection.getShape(), arr);
  13. }

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

  1. public Array readData(Variable v2, Section wantSection) throws IOException, InvalidRangeException {
  2. // raf.seek(0);
  3. raf.order(RandomAccessFile.BIG_ENDIAN);
  4. int size = (int) wantSection.computeSize();
  5. short[] arr = new short[size];
  6. LayoutRegular indexer = new LayoutRegular(0, v2.getElementSize(), v2.getShape(), wantSection);
  7. while (indexer.hasNext()) {
  8. Layout.Chunk chunk = indexer.next();
  9. raf.seek(chunk.getSrcPos());
  10. raf.readShort(arr, (int) chunk.getDestElem(), chunk.getNelems()); // copy into primitive array
  11. }
  12. return Array.factory(v2.getDataType().getPrimitiveClassType(), wantSection.getShape(), arr);
  13. }

相关文章