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

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

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

RandomAccessFile.readShort介绍

[英]Reads a signed 16-bit number from this file. The method reads 2 bytes from this file. If the two bytes read, in order, are b1 and b2, where each of the two values is between 0 and 255, inclusive, then the result is equal to:

(short)((b1 << 8) | b2)

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.
[中]从该文件中读取有符号的16位数字。该方法从该文件中读取2个字节。如果按顺序读取的两个字节分别为b1b2,其中两个值均在0255之间,则结果等于:
(short)((b1 << 8) | b2)
此方法会一直阻塞,直到读取两个字节、检测到流结束或引发异常为止。

代码示例

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. nelems = length / 4;
  4. elem_tag = new short[nelems];
  5. elem_ref = new short[nelems];
  6. for (int i = 0; i < nelems; i++) {
  7. elem_tag[i] = raf.readShort();
  8. elem_ref[i] = raf.readShort();
  9. }
  10. }

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

  1. protected void read() throws IOException {
  2. raf.seek(offset);
  3. nelems = length / 4;
  4. elem_tag = new short[nelems];
  5. elem_ref = new short[nelems];
  6. for (int i = 0; i < nelems; i++) {
  7. elem_tag[i] = raf.readShort();
  8. elem_ref[i] = raf.readShort();
  9. }
  10. }

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. nelems = length / 4;
  4. elem_tag = new short[nelems];
  5. elem_ref = new short[nelems];
  6. for (int i = 0; i < nelems; i++) {
  7. elem_tag[i] = raf.readShort();
  8. elem_ref[i] = raf.readShort();
  9. }
  10. }

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. obj_tagno = raf.readShort();
  4. obj_refno = raf.readShort();
  5. text = readString(length - 4).trim();
  6. }

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

  1. void read() throws IOException {
  2. length = raf.readInt();
  3. first_len = raf.readInt();
  4. blk_len = raf.readShort(); // note size wrong in doc
  5. num_blk = raf.readShort(); // note size wrong in doc
  6. link_ref = raf.readShort();
  7. }

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

  1. void read() throws IOException {
  2. length = raf.readInt();
  3. first_len = raf.readInt();
  4. blk_len = raf.readShort(); // note size wrong in doc
  5. num_blk = raf.readShort(); // note size wrong in doc
  6. link_ref = raf.readShort();
  7. }

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

  1. private void read() throws IOException {
  2. length = raf.readInt();
  3. first_len = raf.readInt();
  4. blk_len = raf.readShort(); // note size wrong in doc
  5. num_blk = raf.readShort(); // note size wrong in doc
  6. link_ref = raf.readShort();
  7. }

代码示例来源: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. }

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

  1. void read() throws IOException {
  2. raf.seek(offset);
  3. obj_tagno = raf.readShort();
  4. obj_refno = raf.readShort();
  5. text = raf.readStringMax(length - 4).trim();
  6. }

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

  1. private int readVariableSize(int size) throws IOException {
  2. long vv;
  3. if (size == 1) {
  4. return raf.readByte();
  5. } else if (size == 2) {
  6. return raf.readShort();
  7. } else if (size == 4) {
  8. return raf.readInt();
  9. }
  10. throw new IllegalArgumentException("Dont support int size == "+size);
  11. }

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

  1. private int readVariableSize(int size) throws IOException {
  2. long vv;
  3. if (size == 1) {
  4. return raf.readByte();
  5. } else if (size == 2) {
  6. return raf.readShort();
  7. } else if (size == 4) {
  8. return raf.readInt();
  9. }
  10. throw new IllegalArgumentException("Dont support int size == " + size);
  11. }

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

  1. private int readVariableSize(int size) throws IOException {
  2. long vv;
  3. if (size == 1) {
  4. return raf.readByte();
  5. } else if (size == 2) {
  6. return raf.readShort();
  7. } else if (size == 4) {
  8. return raf.readInt();
  9. }
  10. throw new IllegalArgumentException("Dont support int size == " + size);
  11. }

代码示例来源: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: Unidata/thredds

  1. Record71() throws IOException {
  2. location = raf.readByte();
  3. raf.readByte(); // skip a byte
  4. messtype = raf.readByte();
  5. index = raf.readShort();
  6. address = h5.readOffset();
  7. }
  8. }

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

  1. Record71() throws IOException {
  2. location = raf.readByte();
  3. raf.readByte(); // skip a byte
  4. messtype = raf.readByte();
  5. index = raf.readShort();
  6. address = h5.readOffset();
  7. }
  8. }

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

  1. Record71() throws IOException {
  2. location = raf.readByte();
  3. raf.readByte(); // skip a byte
  4. messtype = raf.readByte();
  5. index = raf.readShort();
  6. address = h5.readOffset();
  7. }
  8. }

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

  1. Tag(short code) throws IOException {
  2. this.extended = (code & 0x4000) != 0;
  3. this.code = (short) (code & 0x3FFF);
  4. refno = raf.readShort();
  5. offset = raf.readInt();
  6. length = raf.readInt();
  7. t = TagEnum.getTag(this.code);
  8. if ((code > 1) && debugTracker)
  9. memTracker.add(t.getName() + " " + refno, offset, offset + length);
  10. //if (extended)
  11. // System.out.println("");
  12. }

相关文章