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

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

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

void read() throws IOException {
 raf.seek(offset);
 nelems = length / 4;
 elem_tag = new short[nelems];
 elem_ref = new short[nelems];
 for (int i = 0; i < nelems; i++) {
  elem_tag[i] = raf.readShort();
  elem_ref[i] = raf.readShort();
 }
}

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

protected void read() throws IOException {
 raf.seek(offset);
 nelems = length / 4;
 elem_tag = new short[nelems];
 elem_ref = new short[nelems];
 for (int i = 0; i < nelems; i++) {
  elem_tag[i] = raf.readShort();
  elem_ref[i] = raf.readShort();
 }
}

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

void read() throws IOException {
 raf.seek(offset);
 nelems = length / 4;
 elem_tag = new short[nelems];
 elem_ref = new short[nelems];
 for (int i = 0; i < nelems; i++) {
  elem_tag[i] = raf.readShort();
  elem_ref[i] = raf.readShort();
 }
}

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

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

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

void read() throws IOException {
 length = raf.readInt();
 first_len = raf.readInt();
 blk_len = raf.readShort(); // note size wrong in doc
 num_blk = raf.readShort(); // note size wrong in doc
 link_ref = raf.readShort();
}

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

void read() throws IOException {
 length = raf.readInt();
 first_len = raf.readInt();
 blk_len = raf.readShort(); // note size wrong in doc
 num_blk = raf.readShort(); // note size wrong in doc
 link_ref = raf.readShort();
}

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

private void read() throws IOException {
 length = raf.readInt();
 first_len = raf.readInt();
 blk_len = raf.readShort(); // note size wrong in doc
 num_blk = raf.readShort(); // note size wrong in doc
 link_ref = raf.readShort();
}

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

void read() throws IOException {
 raf.seek(offset);
 xdim = raf.readInt();
 ydim = raf.readInt();
 raf.skipBytes(2);
 nt_ref = raf.readShort();
 nelems = raf.readShort();
 interlace = raf.readShort();
 compress = raf.readShort();
 compress_ref = raf.readShort();
}

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

void read() throws IOException {
 raf.seek(offset);
 xdim = raf.readInt();
 ydim = raf.readInt();
 raf.skipBytes(2);
 nt_ref = raf.readShort();
 nelems = raf.readShort();
 interlace = raf.readShort();
 compress = raf.readShort();
 compress_ref = raf.readShort();
}

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

protected void read() throws IOException {
 raf.seek(offset);
 xdim = raf.readInt();
 ydim = raf.readInt();
 raf.skipBytes(2);
 nt_ref = raf.readShort();
 nelems = raf.readShort();
 interlace = raf.readShort();
 compress = raf.readShort();
 compress_ref = raf.readShort();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

Record71() throws IOException {
  location = raf.readByte();
  raf.readByte(); // skip a byte
  messtype = raf.readByte();
  index = raf.readShort();
  address = h5.readOffset();
 }
}

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

Record71() throws IOException {
  location = raf.readByte();
  raf.readByte(); // skip a byte
  messtype = raf.readByte();
  index = raf.readShort();
  address = h5.readOffset();
 }
}

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

Record71() throws IOException {
  location = raf.readByte();
  raf.readByte(); // skip a byte
  messtype = raf.readByte();
  index = raf.readShort();
  address = h5.readOffset();
 }
}

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

Tag(short code) throws IOException {
 this.extended = (code & 0x4000) != 0;
 this.code = (short) (code & 0x3FFF);
 refno = raf.readShort();
 offset = raf.readInt();
 length = raf.readInt();
 t = TagEnum.getTag(this.code);
 if ((code > 1) && debugTracker)
  memTracker.add(t.getName() + " " + refno, offset, offset + length);
 //if (extended)
 //  System.out.println("");
}

相关文章