Package de.undercouch.bson4jackson.io
Class LittleEndianInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
de.undercouch.bson4jackson.io.LittleEndianInputStream
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
Works like
DataInputStream but reads values using
little-endian encoding. Apart from that, it provides a method
that reads an UTF-8 encoded string without reading the number of
bytes from the input stream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteBufferWraps around_rawBufprotected CharBufferA buffer that will lazily be initialized byreadLine()protected byte[]A small buffer to speed up reading slightlyprotected static final StaticBuffers.KeyA unique key for a buffer used inreadUTF(DataInput, int)Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()readLine()longreadLong()shortintintreadUTF()Forwards toDataInputStream.readUTF(DataInput)which expects a short value at the beginning of the UTF-8 string that specifies the number of bytes to read.readUTF(int len) Reads a modified UTF-8 stringReads a modified UTF-8 string from a DataInput objectintskipBytes(int n) Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
UTF8_BUFFER
A unique key for a buffer used inreadUTF(DataInput, int) -
_rawBuf
protected byte[] _rawBufA small buffer to speed up reading slightly -
_buf
Wraps around_rawBuf -
_lineBuffer
A buffer that will lazily be initialized byreadLine()
-
-
Constructor Details
-
LittleEndianInputStream
- See Also:
-
-
Method Details
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
Forwards to
DataInputStream.readUTF(DataInput)which expects a short value at the beginning of the UTF-8 string that specifies the number of bytes to read.If the output stream does no include such a short value, use
readUTF(int)to explicitly specify the number of bytes.- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
readUTF
Reads a modified UTF-8 string- Parameters:
len- the number of bytes to read (please do not mix that up with the number of characters!). If this is -1 then the method will read bytes until the first one is zero (0x00). The zero byte will not be included in the result string.- Returns:
- the UTF-8 string
- Throws:
IOException- if an I/O error occursCharacterCodingException- if an invalid UTF-8 character has been read
-
readUTF
Reads a modified UTF-8 string from a DataInput object- Parameters:
input- the DataInput object to read fromlen- the number of bytes to read (please do not mix that up with the number of characters!). If this is -1 then the method will read bytes until the first one is zero (0x00). The zero byte will not be included in the result string.- Returns:
- the UTF-8 string
- Throws:
IOException- if an I/O error occursCharacterCodingException- if an invalid UTF-8 character has been read
-