Package com.aoindustries.io.stream
Class StreamableInput
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.DataInputStream
-
- com.aoindustries.io.stream.StreamableInput
-
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
public class StreamableInput extends DataInputStream
Adds compressed data transfer to DataInputStream. This class is not thread safe.- Author:
- AO Industries, Inc.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description StreamableInput(InputStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intreadCompressedInt()Reads a compressed integer from the stream.static intreadCompressedInt(InputStream in)Reads a compressed integer from the stream.StringreadCompressedUTF()<T extends Enum<T>>
TreadEnum(Class<T> enumType)Reads anEnum, represented by itsEnum.name().StringreadLongUTF()Reads a string of any length.BooleanreadNullBoolean()BytereadNullByte()<T extends Enum<T>>
TreadNullEnum(Class<T> enumType)IntegerreadNullInteger()LongreadNullLong()StringreadNullLongUTF()Reads a string of any length, supportingnull.ShortreadNullShort()StringreadNullUTF()-
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
StreamableInput
public StreamableInput(InputStream in)
-
-
Method Detail
-
readCompressedInt
public static int readCompressedInt(InputStream in) throws IOException
Reads a compressed integer from the stream. The 31 bit pattern is as follows:5 bit - 000SXXXX 13 bit - 001SXXXX XXXXXXXX 22 bit - 01SXXXXX XXXXXXXX XXXXXXXX 31 bit - 1SXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- Throws:
EOFException- if the end of file is reachedIOException
-
readCompressedInt
public int readCompressedInt() throws IOExceptionReads a compressed integer from the stream. The 31 bit pattern is as follows:5 bit - 000SXXXX 13 bit - 001SXXXX XXXXXXXX 22 bit - 01SXXXXX XXXXXXXX XXXXXXXX 31 bit - 1SXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- Throws:
EOFException- if the end of file is reachedIOException
-
readCompressedUTF
public String readCompressedUTF() throws IOException
- Throws:
EOFException- if the end of file is reachedIOException
-
readNullUTF
public String readNullUTF() throws IOException
- Throws:
IOException
-
readLongUTF
public String readLongUTF() throws IOException
Reads a string of any length.- Throws:
IOException
-
readNullLongUTF
public String readNullLongUTF() throws IOException
Reads a string of any length, supportingnull.- Throws:
IOException
-
readNullByte
public Byte readNullByte() throws IOException
- Throws:
IOException
-
readNullShort
public Short readNullShort() throws IOException
- Throws:
IOException
-
readNullInteger
public Integer readNullInteger() throws IOException
- Throws:
IOException
-
readNullLong
public Long readNullLong() throws IOException
- Throws:
IOException
-
readEnum
public <T extends Enum<T>> T readEnum(Class<T> enumType) throws IOException
Reads anEnum, represented by itsEnum.name().- Throws:
IOException
-
readNullEnum
public <T extends Enum<T>> T readNullEnum(Class<T> enumType) throws IOException
- Throws:
IOException
-
readNullBoolean
public Boolean readNullBoolean() throws IOException
- Throws:
IOException
-
-