@InterfaceAudience.Private public class StreamUtils extends Object
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte |
readByte(InputStream in)
Read a byte from the given stream using the read method, and throw EOFException if it returns
-1, like the implementation in
DataInputStream. |
static long |
readLong(InputStream in) |
static Pair<Integer,Integer> |
readRawVarint32(byte[] input,
int offset)
Reads a varInt value stored in an array.
|
static int |
readRawVarint32(ByteBuff input) |
static Pair<Integer,Integer> |
readRawVarint32(ByteBuffer input,
int offset) |
static int |
readRawVarint32(InputStream input) |
static short |
toShort(byte hi,
byte lo) |
static void |
writeInt(OutputStream out,
int v) |
static void |
writeLong(OutputStream out,
long v) |
static void |
writeRawVInt32(OutputStream output,
int value) |
static void |
writeShort(OutputStream out,
short v) |
public static void writeRawVInt32(OutputStream output, int value) throws IOException
IOExceptionpublic static int readRawVarint32(InputStream input) throws IOException
IOExceptionpublic static int readRawVarint32(ByteBuff input) throws IOException
IOExceptionpublic static Pair<Integer,Integer> readRawVarint32(byte[] input, int offset) throws IOException
IOException - When varint is malformed and not able to be read correctlypublic static Pair<Integer,Integer> readRawVarint32(ByteBuffer input, int offset) throws IOException
IOExceptionpublic static byte readByte(InputStream in) throws IOException
DataInputStream.
This is useful because casting the return value of read method into byte directly will make us
lose the ability to check whether there is a byte and its value is -1 or we reach EOF, as
casting int -1 to byte also returns -1.IOExceptionpublic static short toShort(byte hi,
byte lo)
public static void writeShort(OutputStream out, short v) throws IOException
IOExceptionpublic static void writeInt(OutputStream out, int v) throws IOException
IOExceptionpublic static void writeLong(OutputStream out, long v) throws IOException
IOExceptionpublic static long readLong(InputStream in) throws IOException
IOExceptionCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.