okio.BufferedSource.readLongLe()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(121)

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

BufferedSource.readLongLe介绍

[英]Removes eight bytes from this source and returns a little-endian long.
[中]从该源中删除八个字节,并返回一个稍长的endian。

代码示例

代码示例来源:origin: square/wire

/** Reads a 64-bit little-endian integer from the stream. */
public long readFixed64() throws IOException {
 if (state != STATE_FIXED64 && state != STATE_LENGTH_DELIMITED) {
  throw new ProtocolException("Expected FIXED64 or LENGTH_DELIMITED but was " + state);
 }
 source.require(8); // Throws EOFException if insufficient bytes are available.
 pos += 8;
 long result = source.readLongLe();
 afterPackableScalar(STATE_FIXED64);
 return result;
}

代码示例来源:origin: square/okio

@Test public void readLongLe() throws Exception {
 sink.write(new byte[] {
   (byte) 0xab, (byte) 0xcd, (byte) 0xef, (byte) 0x10, (byte) 0x87, (byte) 0x65, (byte) 0x43,
   (byte) 0x21, (byte) 0x36, (byte) 0x47, (byte) 0x58, (byte) 0x69, (byte) 0x12, (byte) 0x23,
   (byte) 0x34, (byte) 0x45
 });
 sink.emit();
 assertEquals(0x2143658710efcdabL, source.readLongLe());
 assertEquals(0x4534231269584736L, source.readLongLe());
 assertTrue(source.exhausted());
}

代码示例来源:origin: square/okio

@Test public void readLongLeTooShortThrows() throws IOException {
 sink.writeLongLe(Long.MAX_VALUE);
 sink.emit();
 source.readByte();
 try {
  source.readLongLe();
  fail();
 } catch (EOFException expected) {
 }
}

代码示例来源:origin: com.squareup.wire/wire-runtime

/** Reads a 64-bit little-endian integer from the stream. */
public long readFixed64() throws IOException {
 if (state != STATE_FIXED64 && state != STATE_LENGTH_DELIMITED) {
  throw new ProtocolException("Expected FIXED64 or LENGTH_DELIMITED but was " + state);
 }
 source.require(8); // Throws EOFException if insufficient bytes are available.
 pos += 8;
 long result = source.readLongLe();
 afterPackableScalar(STATE_FIXED64);
 return result;
}

相关文章

微信公众号

最新文章

更多