本文整理了Java中okio.BufferedSource.readIntLe()
方法的一些代码示例,展示了BufferedSource.readIntLe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedSource.readIntLe()
方法的具体详情如下:
包路径:okio.BufferedSource
类名称:BufferedSource
方法名:readIntLe
[英]Removes four bytes from this source and returns a little-endian int.
[中]从该源中删除四个字节并返回一个小的endian int。
代码示例来源:origin: square/wire
/** Reads a 32-bit little-endian integer from the stream. */
public int readFixed32() throws IOException {
if (state != STATE_FIXED32 && state != STATE_LENGTH_DELIMITED) {
throw new ProtocolException("Expected FIXED32 or LENGTH_DELIMITED but was " + state);
}
source.require(4); // Throws EOFException if insufficient bytes are available.
pos += 4;
int result = source.readIntLe();
afterPackableScalar(STATE_FIXED32);
return result;
}
代码示例来源:origin: square/okio
@Test public void readIntLe() throws Exception {
sink.write(new byte[] {
(byte) 0xab, (byte) 0xcd, (byte) 0xef, (byte) 0x10, (byte) 0x87, (byte) 0x65, (byte) 0x43,
(byte) 0x21
});
sink.emit();
assertEquals(0x10efcdab, source.readIntLe());
assertEquals(0x21436587, source.readIntLe());
assertTrue(source.exhausted());
}
代码示例来源:origin: square/okio
@Test public void readIntLeTooShortThrows() throws IOException {
sink.writeIntLe(Integer.MAX_VALUE);
sink.emit();
source.readByte();
try {
source.readIntLe();
fail();
} catch (EOFException expected) {
}
}
代码示例来源:origin: huxq17/tractor
private void consumeTrailer() throws IOException {
// Read the eight-byte trailer. Confirm the body's CRC and size.
// +---+---+---+---+---+---+---+---+
// | CRC32 | ISIZE |
// +---+---+---+---+---+---+---+---+
checkEqual("CRC", source.readIntLe(), (int) crc.getValue());
checkEqual("ISIZE", source.readIntLe(), inflater.getTotalOut());
}
代码示例来源:origin: com.squareup.wire/wire-runtime
/** Reads a 32-bit little-endian integer from the stream. */
public int readFixed32() throws IOException {
if (state != STATE_FIXED32 && state != STATE_LENGTH_DELIMITED) {
throw new ProtocolException("Expected FIXED32 or LENGTH_DELIMITED but was " + state);
}
source.require(4); // Throws EOFException if insufficient bytes are available.
pos += 4;
int result = source.readIntLe();
afterPackableScalar(STATE_FIXED32);
return result;
}
代码示例来源:origin: codeka/wwmmo
@Override
public void run() {
try {
while (!source.exhausted()) {
int size = source.readIntLe();
int flags = source.readIntLe();
byte[] bytes = source.readByteArray(size);
if ((flags & PacketFlags.COMPRESSED) != 0) {
bytes = GzipHelper.decompress(bytes);
}
Packet pkt = Packet.ADAPTER.decode(bytes);
handler.onPacket(PacketDecoder.this, pkt, size);
}
} catch(IOException e) {
log.warning("Error decoding packet.", e);
handler.onDisconnect();
}
}
};
内容来源于网络,如有侵权,请联系作者删除!