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

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

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

RandomAccessFile.readLong介绍

[英]Reads a signed 64-bit integer from this file. This method reads eight bytes from the file. If the bytes read, in order, are b1, b2, b3, b4, b5, b6, b7, and b8, where:

0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,

then the result is equal to:

  1. ((long)b1 << 56) + ((long)b2 << 48)
  2. + ((long)b3 << 40) + ((long)b4 << 32)
  3. + ((long)b5 << 24) + ((long)b6 << 16)
  4. + ((long)b7 << 8) + b8

This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.
[中]从该文件中读取带符号的64位整数。此方法从文件中读取八个字节。如果按顺序读取的字节为b1b2b3b4b5b6b7b8,,其中:
0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
那么结果等于:

  1. ((long)b1 << 56) + ((long)b2 << 48)
  2. + ((long)b3 << 40) + ((long)b4 << 32)
  3. + ((long)b5 << 24) + ((long)b6 << 16)
  4. + ((long)b7 << 8) + b8

此方法会一直阻塞,直到读取了八个字节、检测到流结束或引发异常为止。

代码示例

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

  1. /**
  2. * Read an array of longs
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readLong(long[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = readLong();
  12. }
  13. }

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

  1. /**
  2. * Read an array of longs
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readLong(long[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = readLong();
  12. }
  13. }

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

  1. /**
  2. * Read an array of longs
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readLong(long[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = readLong();
  12. }
  13. }

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

  1. /**
  2. * Read an array of longs
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readLong(long[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = readLong();
  12. }
  13. }

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

  1. /**
  2. * Read an array of doubles
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readDouble(double[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = Double.longBitsToDouble(readLong());
  12. }
  13. }

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

  1. /**
  2. * Read an array of doubles
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readDouble(double[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = Double.longBitsToDouble(readLong());
  12. }
  13. }

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

  1. /**
  2. * Read an array of doubles
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readDouble(double[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = Double.longBitsToDouble(readLong());
  12. }
  13. }

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

  1. /**
  2. * Read an array of doubles
  3. *
  4. * @param pa read into this array
  5. * @param start starting at pa[start]
  6. * @param n read this many elements
  7. * @throws IOException on read error
  8. */
  9. public final void readDouble(double[] pa, int start, int n) throws IOException {
  10. for (int i = 0; i < n; i++) {
  11. pa[start + i] = Double.longBitsToDouble(readLong());
  12. }
  13. }

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

  1. long readLength() throws IOException {
  2. return isLengthLong ? raf.readLong() : (long) raf.readInt();
  3. }

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

  1. long readLength() throws IOException {
  2. return isLengthLong ? raf.readLong() : (long) raf.readInt();
  3. }

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

  1. long readOffset() throws IOException {
  2. return isOffsetLong ? raf.readLong() : (long) raf.readInt();
  3. }

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

  1. long readLength() throws IOException {
  2. return isLengthLong ? raf.readLong() : (long) raf.readInt();
  3. }

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

  1. Record6() throws IOException {
  2. creationOrder = raf.readLong();
  3. raf.readFully(heapId);
  4. if (debugBtree2)
  5. debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
  6. }
  7. }

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

  1. Record6() throws IOException {
  2. creationOrder = raf.readLong();
  3. raf.read(heapId);
  4. if (debugBtree2)
  5. debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
  6. }
  7. }

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

  1. Record6() throws IOException {
  2. creationOrder = raf.readLong();
  3. raf.readFully(heapId);
  4. if (debugBtree2)
  5. debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
  6. }
  7. }

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

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

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

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

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

  1. DataChunk(int ndim, boolean last) throws IOException {
  2. this.size = h5.raf.readInt();
  3. this.filterMask = h5.raf.readInt();
  4. offset = new int[ndim];
  5. for (int i = 0; i < ndim; i++) {
  6. long loffset = h5.raf.readLong();
  7. assert loffset < Integer.MAX_VALUE;
  8. offset[i] = (int) loffset;
  9. }
  10. this.filePos = last ? -1 : h5.readAddress(); //
  11. if (memTracker != null) memTracker.addByLen("Chunked Data (" + owner + ")", filePos, size);
  12. }

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

  1. DataChunk(int ndim, boolean last) throws IOException {
  2. this.size = raf.readInt();
  3. this.filterMask = raf.readInt();
  4. offset = new int[ndim];
  5. for (int i = 0; i < ndim; i++) {
  6. long loffset = raf.readLong();
  7. assert loffset < Integer.MAX_VALUE;
  8. offset[i] = (int) loffset;
  9. }
  10. this.filePos = last ? -1 : h5.readAddress(); //
  11. if (memTracker != null) memTracker.addByLen("Chunked Data (" + owner + ")", filePos, size);
  12. }

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

  1. DataChunk(int ndim, boolean last) throws IOException {
  2. this.size = raf.readInt();
  3. this.filterMask = raf.readInt();
  4. offset = new int[ndim];
  5. for (int i = 0; i < ndim; i++) {
  6. long loffset = raf.readLong();
  7. assert loffset < Integer.MAX_VALUE;
  8. offset[i] = (int) loffset;
  9. }
  10. this.filePos = last ? -1 : h5.readAddress(); //
  11. if (memTracker != null) memTracker.addByLen("Chunked Data (" + owner + ")", filePos, size);
  12. }

相关文章