public class Input
extends java.io.InputStream
| Constructor and Description |
|---|
Input()
Creates an uninitialized Input.
|
Input(byte[] buffer)
Creates a new Input for reading from a byte array.
|
Input(byte[] buffer,
int offset,
int count)
Creates a new Input for reading from a byte array.
|
Input(java.io.InputStream inputStream)
Creates a new Input for reading from an InputStream with a buffer size of 4096.
|
Input(java.io.InputStream inputStream,
int bufferSize)
Creates a new Input for reading from an InputStream.
|
Input(int bufferSize)
Creates a new Input for reading from a byte array.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
boolean |
canReadInt()
Returns true if enough bytes are available to read an int with
readInt(boolean). |
boolean |
canReadLong()
Returns true if enough bytes are available to read a long with
readLong(boolean). |
void |
close()
Closes the underlying InputStream, if any.
|
boolean |
eof() |
byte[] |
getBuffer() |
java.io.InputStream |
getInputStream() |
int |
limit()
Returns the limit for the buffer.
|
int |
position()
Returns the current position in the buffer.
|
int |
read()
Reads a single byte as an int from 0 to 255, or -1 if there are no more bytes are available.
|
int |
read(byte[] bytes)
Reads bytes.length bytes or less and writes them to the specified byte[], starting at 0, and returns the number of bytes
read.
|
int |
read(byte[] bytes,
int offset,
int count)
Reads count bytes or less and writes them to the specified byte[], starting at offset, and returns the number of bytes read
or -1 if no more bytes are available.
|
boolean |
readBoolean()
Reads a 1 byte boolean.
|
byte |
readByte()
Reads a single byte.
|
void |
readBytes(byte[] bytes)
Reads bytes.length bytes and writes them to the specified byte[], starting at index 0.
|
void |
readBytes(byte[] bytes,
int offset,
int count)
Reads count bytes and writes them to the specified byte[], starting at offset.
|
byte[] |
readBytes(int length)
Reads the specified number of bytes into a new byte[].
|
int |
readByteUnsigned()
Reads a byte as an int from 0 to 255.
|
char |
readChar()
Reads a 2 byte char.
|
double |
readDouble()
Reads an 8 bytes double.
|
double |
readDouble(double precision,
boolean optimizePositive)
Reads a 1-9 byte double with reduced precision.
|
float |
readFloat()
Reads a 4 byte float.
|
float |
readFloat(float precision,
boolean optimizePositive)
Reads a 1-5 byte float with reduced precision.
|
int |
readInt()
Reads a 4 byte int.
|
int |
readInt(boolean optimizePositive)
Reads a 1-5 byte int.
|
long |
readLong()
Reads an 8 byte long.
|
long |
readLong(boolean optimizePositive)
Reads a 1-9 byte long.
|
short |
readShort()
Reads a 2 byte short.
|
int |
readShortUnsigned()
Reads a 2 byte short as an int from 0 to 65535.
|
java.lang.String |
readString()
Reads the length and string of UTF8 characters, or null.
|
java.lang.StringBuilder |
readStringBuilder()
Reads the length and string of UTF8 characters, or null.
|
void |
rewind()
Sets the position and total to zero.
|
void |
setBuffer(byte[] bytes)
Sets a new buffer.
|
void |
setBuffer(byte[] bytes,
int offset,
int count)
Sets a new buffer.
|
void |
setInputStream(java.io.InputStream inputStream)
Sets a new InputStream.
|
void |
setLimit(int limit)
Sets the limit in the buffer.
|
void |
setPosition(int position)
Sets the current position in the buffer.
|
void |
setTotal(int total)
Sets the number of bytes read.
|
void |
skip(int count)
Discards the specified number of bytes.
|
long |
skip(long count)
Discards the specified number of bytes.
|
int |
total()
Returns the number of bytes read.
|
public Input()
setBuffer(byte[]) must be called before the Input is used.public Input(int bufferSize)
bufferSize - The size of the buffer. An exception is thrown if more bytes than this are read.public Input(byte[] buffer)
buffer - An exception is thrown if more bytes than this are read.public Input(byte[] buffer,
int offset,
int count)
buffer - An exception is thrown if more bytes than this are read.public Input(java.io.InputStream inputStream)
public Input(java.io.InputStream inputStream,
int bufferSize)
public void setBuffer(byte[] bytes)
public void setBuffer(byte[] bytes,
int offset,
int count)
public byte[] getBuffer()
public java.io.InputStream getInputStream()
public void setInputStream(java.io.InputStream inputStream)
inputStream - May be null.public int total()
public void setTotal(int total)
public int position()
public void setPosition(int position)
public int limit()
public void setLimit(int limit)
public void rewind()
public void skip(int count)
throws KryoException
KryoExceptionpublic boolean eof()
public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic int read()
throws KryoException
read in class java.io.InputStreamKryoExceptionpublic int read(byte[] bytes)
throws KryoException
read in class java.io.InputStreamKryoExceptionpublic int read(byte[] bytes,
int offset,
int count)
throws KryoException
read in class java.io.InputStreamKryoExceptionpublic long skip(long count)
throws KryoException
skip in class java.io.InputStreamKryoExceptionpublic void close()
throws KryoException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamKryoExceptionpublic byte readByte()
throws KryoException
KryoExceptionpublic int readByteUnsigned()
throws KryoException
KryoExceptionpublic byte[] readBytes(int length)
throws KryoException
KryoExceptionpublic void readBytes(byte[] bytes)
throws KryoException
KryoExceptionpublic void readBytes(byte[] bytes,
int offset,
int count)
throws KryoException
KryoExceptionpublic int readInt()
throws KryoException
KryoExceptionpublic int readInt(boolean optimizePositive)
throws KryoException
KryoExceptionpublic boolean canReadInt()
throws KryoException
readInt(boolean).KryoExceptionpublic boolean canReadLong()
throws KryoException
readLong(boolean).KryoExceptionpublic java.lang.String readString()
Output.writeString(String)
, Output.writeString(CharSequence), and Output.writeAscii(String).public java.lang.StringBuilder readStringBuilder()
Output.writeString(String)
, Output.writeString(CharSequence), and Output.writeAscii(String).public float readFloat()
throws KryoException
KryoExceptionpublic float readFloat(float precision,
boolean optimizePositive)
throws KryoException
KryoExceptionpublic short readShort()
throws KryoException
KryoExceptionpublic int readShortUnsigned()
throws KryoException
KryoExceptionpublic long readLong()
throws KryoException
KryoExceptionpublic long readLong(boolean optimizePositive)
throws KryoException
KryoExceptionpublic boolean readBoolean()
throws KryoException
KryoExceptionpublic char readChar()
throws KryoException
KryoExceptionpublic double readDouble()
throws KryoException
KryoExceptionpublic double readDouble(double precision,
boolean optimizePositive)
throws KryoException
KryoException