java.io.RandomAccessFile.readUnsignedShort()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(148)

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

RandomAccessFile.readUnsignedShort介绍

[英]Reads an unsigned big-endian 16-bit short from the current position in this file and returns it as an integer. Blocks until two bytes have been read, the end of the file is reached or an exception is thrown.
[中]从文件中的当前位置读取一个无符号的16位大端字节,并将其作为整数返回。块,直到读取两个字节、到达文件结尾或引发异常为止。

代码示例

代码示例来源:origin: oracle/opengrok

public FNode(RandomAccessFile f) throws Throwable {
  offset = f.getFilePointer();
  hash = f.readLong();
  childOffset = f.readUnsignedShort();
  numChildren = f.readUnsignedShort();
  tagOffset = f.readUnsignedShort();
}

代码示例来源:origin: oracle/opengrok

public FNode() throws IOException {
  offset = f.getFilePointer();
  try {
    hash = f.readLong();
    childOffset = f.readUnsignedShort();
    numChildren = f.readUnsignedShort();
    tagOffset = f.readUnsignedShort();
  } catch (EOFException e) {
    numChildren = 0;
    tagOffset = 0;
  }
}

代码示例来源:origin: oracle/opengrok

private FNode binarySearch(long start, int len, long hash) throws IOException {
  int b = 0;
  int e = len;
  while (b <= e) {
    int m = (b + e) / 2;
    f.seek(start + m * EftarFile.RECORD_LENGTH);
    long mhash = f.readLong();
    if (hash > mhash) {
      b = m + 1;
    } else if (hash < mhash) {
      e = m - 1;
    } else {
      return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort());
    }
  }
  return null;
}

代码示例来源:origin: oracle/opengrok

private FNode sbinSearch(long start, int len, long hash, RandomAccessFile f) throws Throwable {
    int b = 0;
    int e = len;
    while (b <= e) {
      int m = (b + e) / 2;
      f.seek(start + m * RECORD_LENGTH);
      long mhash = f.readLong();
      if (hash > mhash) {
        b = m + 1;
      } else if (hash < mhash) {
        e = m - 1;
      } else {
        return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort());
      }
    }
    return null;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Reads a string that is encoded in {@link DataInput modified UTF-8} from
 * this file. The number of bytes that must be read for the complete string
 * is determined by the first two bytes read from the file. Blocks until all
 * required bytes have been read, the end of the file is reached or an
 * exception is thrown.
 *
 * @return the next string encoded in {@link DataInput modified UTF-8} from
 *         this file.
 * @throws EOFException
 *             if the end of this file is detected.
 * @throws IOException
 *             if this file is closed or another I/O error occurs.
 * @throws UTFDataFormatException
 *             if the bytes read cannot be decoded into a character string.
 * @see #writeUTF(String)
 */
public final String readUTF() throws IOException {
  int utfSize = readUnsignedShort();
  if (utfSize == 0) {
    return "";
  }
  byte[] buf = new byte[utfSize];
  if (read(buf, 0, buf.length) != buf.length) {
    throw new EOFException();
  }
  return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize);
}

代码示例来源:origin: apache/activemq

@Override
public int readUnsignedShort() throws IOException {
  try {
    return getRaf().readUnsignedShort();
  } catch (IOException ioe) {
    handleException();
    throw ioe;
  }
}

代码示例来源:origin: apache/pdfbox

/**
 * Read an unsigned short.
 * 
 * @return An unsigned short.
 * @throws IOException If there is an error reading the data.
 * @see RandomAccessFile#readUnsignedShort()
 */
@Override
public int readUnsignedShort() throws IOException
{
  return raf.readUnsignedShort();
}

代码示例来源:origin: i2p/i2p.i2p

public int readUnsignedShort()		throws IOException { return delegate.readUnsignedShort(); }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new CoverageFormat1 */
protected CoverageFormat1(RandomAccessFile raf) throws IOException {
  glyphCount = raf.readUnsignedShort();
  glyphIds = new int[glyphCount];
  for (int i = 0; i < glyphCount; i++) {
    glyphIds[i] = raf.readUnsignedShort();
  }
}

代码示例来源:origin: de.sciss/scisslib

protected final int readLittleUShort()
throws IOException
{
  final int i = raf.readUnsignedShort();
  return( (i >> 8) | ((i & 0xFF) << 8) );
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new LangSys */
protected LangSys(RandomAccessFile raf) throws IOException {
  lookupOrder = raf.readUnsignedShort();
  reqFeatureIndex = raf.readUnsignedShort();
  featureCount = raf.readUnsignedShort();
  featureIndex = new int[featureCount];
  for (int i = 0; i < featureCount; i++) {
    featureIndex[i] = raf.readUnsignedShort();
  }
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new Feature */
protected Feature(RandomAccessFile raf, int offset) throws IOException {
  raf.seek(offset);
  featureParams = raf.readUnsignedShort();
  lookupCount = raf.readUnsignedShort();
  lookupListIndex = new int[lookupCount];
  for (int i = 0; i < lookupCount; i++) {
    lookupListIndex[i] = raf.readUnsignedShort();
  }
}

代码示例来源:origin: apache/batik

protected CmapIndexEntry(RandomAccessFile raf) throws IOException {
  platformId = raf.readUnsignedShort();
  encodingId = raf.readUnsignedShort();
  offset = raf.readInt();
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new KernSubtableFormat0 */
protected KernSubtableFormat0(RandomAccessFile raf) throws IOException {
  nPairs = raf.readUnsignedShort();
  searchRange = raf.readUnsignedShort();
  entrySelector = raf.readUnsignedShort();
  rangeShift = raf.readUnsignedShort();
  kerningPairs = new KerningPair[nPairs];
  for (int i = 0; i < nPairs; i++) {
    kerningPairs[i] = new KerningPair(raf);
  }
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new SingleSubstFormat2 */
protected SingleSubstFormat2(RandomAccessFile raf, int offset) throws IOException {
  coverageOffset = raf.readUnsignedShort();
  glyphCount = raf.readUnsignedShort();
  substitutes = new int[glyphCount];
  for (int i = 0; i < glyphCount; i++) {
    substitutes[i] = raf.readUnsignedShort();
  }
  raf.seek(offset + coverageOffset);
  coverage = Coverage.read(raf);
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/** Creates new CoverageFormat2 */
protected CoverageFormat2(RandomAccessFile raf) throws IOException {
  rangeCount = raf.readUnsignedShort();
  rangeRecords = new RangeRecord[rangeCount];
  for (int i = 0; i < rangeCount; i++) {
    rangeRecords[i] = new RangeRecord(raf);
  }
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

@Override
public int readUnsignedShort(long offset) {
 checkRead(offset, SHORT);
 try {
  seekToOffset(offset);
  return randomAccessFile.readUnsignedShort();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

protected static ClassDef read(final RandomAccessFile raf) throws IOException {
    ClassDef c = null;
    final int format = raf.readUnsignedShort();
    if (format == 1) {
      c = new ClassDefFormat1(raf);
    } else if (format == 2) {
      c = new ClassDefFormat2(raf);
    }
    return c;
  }
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

protected static Coverage read(RandomAccessFile raf) throws IOException {
  Coverage c = null;
  int format = raf.readUnsignedShort();
  if (format == 1) {
    c = new CoverageFormat1(raf);
  } else if (format == 2) {
    c = new CoverageFormat2(raf);
  }
  return c;
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

protected static ClassDef read(RandomAccessFile raf) throws IOException {
    ClassDef c = null;
    int format = raf.readUnsignedShort();
    if (format == 1) {
      c = new ClassDefFormat1(raf);
    } else if (format == 2) {
      c = new ClassDefFormat2(raf);
    }
    return c;
  }
}

相关文章