public class Io
extends java.lang.Object
| Modifier and Type | Method | Description |
|---|---|---|
static void |
close(java.io.Closeable closeable) |
Closes the given
Closeable, ignoring any possible I/O exception. |
static int |
copyBytes(java.io.InputStream source,
java.io.OutputStream destination) |
Copies all bytes from the given source to the given destination.
|
static void |
copyBytes(java.io.InputStream source,
java.io.OutputStream destination,
int byteCount) |
Copies the given number of bytes from the given source to the given destination.
|
static int |
discardBytes(java.io.InputStream source) |
Discards all bytes from the given source.
|
static void |
discardBytes(java.io.InputStream source,
int byteCount) |
Discards the given number of bytes from the given source.
|
static int |
getBufferSize() |
Returns the size of the buffer (in bytes) used in I/O operations.
|
static byte |
readByte(java.io.InputStream source) |
Reads a
byte from the given source. |
static byte[] |
readBytes(java.io.InputStream source) |
Reads all bytes from the given source.
|
static byte[] |
readBytes(java.io.InputStream source,
int byteCount) |
Reads the given number of bytes from the given source.
|
static char |
readChar(java.io.InputStream source) |
Reads a
char from the given source using the default (big-endian) byte order. |
static char |
readChar(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
char from the given source using the given byte order. |
static double |
readDouble(java.io.InputStream source) |
Reads a
double from the given source using the default (big-endian) byte order. |
static double |
readDouble(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
double from the given source using the given byte order. |
static float |
readFloat(java.io.InputStream source) |
Reads a
float from the given source using the default (big-endian) byte order. |
static float |
readFloat(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
float from the given source using the given byte order. |
static int |
readInt(java.io.InputStream source) |
Reads an
int from the given source using the default (big-endian) byte order. |
static int |
readInt(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads an
int from the given source using the given byte order. |
static long |
readLong(java.io.InputStream source) |
Reads a
long from the given source using the default (big-endian) byte order. |
static long |
readLong(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
long from the given source using the given byte order. |
static short |
readShort(java.io.InputStream source) |
Reads a
short from the given source using the default (big-endian) byte order. |
static short |
readShort(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
short from the given source using the given byte order. |
static java.lang.String |
readString(java.io.InputStream source) |
Reads all bytes from the given source and converts them to a string using UTF-8.
|
static java.lang.String |
readString(java.io.InputStream source,
int byteCount) |
Reads the given number of bytes from the given source and converts them to a string using UTF-8.
|
static java.lang.String |
readString(java.io.InputStream source,
int byteCount,
java.nio.charset.Charset charset) |
Reads the given number of bytes from the given source and converts them to a string using the given charset.
|
static java.lang.String |
readString(java.io.InputStream source,
java.nio.charset.Charset charset) |
Reads all bytes from the given source and converts them to a string using the given charset.
|
static int |
readUnsignedByte(java.io.InputStream source) |
Reads an unsigned
byte from the given source. |
static java.util.UUID |
readUuid(java.io.InputStream source) |
Reads a
UUID} from the given source using the default (big-endian) byte order. |
static java.util.UUID |
readUuid(java.io.InputStream source,
java.nio.ByteOrder byteOrder) |
Reads a
UUID} from the given source using the given byte order. |
static void |
setBufferSize(int bufferSize) |
Sets the size of the buffer (in bytes) used in I/O operations.
|
static void |
writeByte(java.io.OutputStream destination,
byte value) |
Writes a
byte to the given destination. |
static void |
writeBytes(java.io.OutputStream destination,
byte[] bytes) |
Writes the given bytes to the given destination.
|
static void |
writeChar(java.io.OutputStream destination,
char value) |
Writes a
char to the given destination using the default (big-endian) byte order. |
static void |
writeChar(java.io.OutputStream destination,
char value,
java.nio.ByteOrder byteOrder) |
Writes a
char to the given destination using the given byte order. |
static void |
writeDouble(java.io.OutputStream destination,
double value) |
Writes a
double to the given destination using the default (big-endian) byte order. |
static void |
writeDouble(java.io.OutputStream destination,
double value,
java.nio.ByteOrder byteOrder) |
Writes a
double to the given destination using the given byte order. |
static void |
writeFloat(java.io.OutputStream destination,
float value) |
Writes a
float to the given destination using the default (big-endian) byte order. |
static void |
writeFloat(java.io.OutputStream destination,
float value,
java.nio.ByteOrder byteOrder) |
Writes a
float to the given destination using the given byte order. |
static void |
writeInt(java.io.OutputStream destination,
int value) |
Writes an
int to the given destination using the default (big-endian) byte order. |
static void |
writeInt(java.io.OutputStream destination,
int value,
java.nio.ByteOrder byteOrder) |
Writes an
int to the given destination using the given byte order. |
static void |
writeLong(java.io.OutputStream destination,
long value) |
Writes a
long to the given destination using the default (big-endian) byte order. |
static void |
writeLong(java.io.OutputStream destination,
long value,
java.nio.ByteOrder byteOrder) |
Writes a
long to the given destination using the given byte order. |
static void |
writeShort(java.io.OutputStream destination,
short value) |
Writes a
short to the given destination using the default (big-endian) byte order. |
static void |
writeShort(java.io.OutputStream destination,
short value,
java.nio.ByteOrder byteOrder) |
Writes a
short to the given destination using the given byte order. |
static void |
writeString(java.io.OutputStream destination,
java.lang.String string) |
Writes the given string to the given destination using UTF-8.
|
static void |
writeString(java.io.OutputStream destination,
java.lang.String string,
java.nio.charset.Charset charset) |
Writes the given string to the given destination using the given charset.
|
static void |
writeUnsignedByte(java.io.OutputStream destination,
int value) |
Writes an unsigned
byte to the given destination. |
static void |
writeUuid(java.io.OutputStream destination,
java.util.UUID uuid) |
Writes a
UUID to the given destination using the default (big-endian) byte order. |
static void |
writeUuid(java.io.OutputStream destination,
java.util.UUID uuid,
java.nio.ByteOrder byteOrder) |
Writes a
UUID to the given destination using the given byte order. |
public static void close(java.io.Closeable closeable)
Closeable, ignoring any possible I/O exception.public static int copyBytes(java.io.InputStream source,
java.io.OutputStream destination)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void copyBytes(java.io.InputStream source,
java.io.OutputStream destination,
int byteCount)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static int discardBytes(java.io.InputStream source)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static void discardBytes(java.io.InputStream source,
int byteCount)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static int getBufferSize()
public static byte readByte(java.io.InputStream source)
throws java.io.IOException
byte from the given source.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static byte[] readBytes(java.io.InputStream source)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static byte[] readBytes(java.io.InputStream source,
int byteCount)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static char readChar(java.io.InputStream source)
throws java.io.IOException
char from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static char readChar(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
char from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static double readDouble(java.io.InputStream source)
throws java.io.IOException
double from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static double readDouble(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
double from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static float readFloat(java.io.InputStream source)
throws java.io.IOException
float from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static float readFloat(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
float from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static int readInt(java.io.InputStream source)
throws java.io.IOException
int from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static int readInt(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
int from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static long readLong(java.io.InputStream source)
throws java.io.IOException
long from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static long readLong(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
long from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static short readShort(java.io.InputStream source)
throws java.io.IOException
short from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static short readShort(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
short from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static java.lang.String readString(java.io.InputStream source)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static java.lang.String readString(java.io.InputStream source,
java.nio.charset.Charset charset)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if charset is nulljava.io.IOException - if an I/O error occurspublic static java.lang.String readString(java.io.InputStream source,
int byteCount)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static java.lang.String readString(java.io.InputStream source,
int byteCount,
java.nio.charset.Charset charset)
throws java.io.IOException
java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if charset is nulljava.io.IOException - if an I/O error occurspublic static int readUnsignedByte(java.io.InputStream source)
throws java.io.IOException
byte from the given source.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static java.util.UUID readUuid(java.io.InputStream source)
throws java.io.IOException
UUID} from the given source using the default (big-endian) byte order.java.lang.IllegalArgumentException - if source is nulljava.io.IOException - if an I/O error occurspublic static java.util.UUID readUuid(java.io.InputStream source,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
UUID} from the given source using the given byte order.java.lang.IllegalArgumentException - if source is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void setBufferSize(int bufferSize)
java.lang.IllegalArgumentException - if bufferSize is not positivepublic static void writeByte(java.io.OutputStream destination,
byte value)
throws java.io.IOException
byte to the given destination.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeBytes(java.io.OutputStream destination,
byte[] bytes)
throws java.io.IOException
java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if bytes are nulljava.io.IOException - if an I/O error occurspublic static void writeChar(java.io.OutputStream destination,
char value)
throws java.io.IOException
char to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeChar(java.io.OutputStream destination,
char value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
char to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeDouble(java.io.OutputStream destination,
double value)
throws java.io.IOException
double to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeDouble(java.io.OutputStream destination,
double value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
double to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeFloat(java.io.OutputStream destination,
float value)
throws java.io.IOException
float to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeFloat(java.io.OutputStream destination,
float value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
float to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeInt(java.io.OutputStream destination,
int value)
throws java.io.IOException
int to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeInt(java.io.OutputStream destination,
int value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
int to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeLong(java.io.OutputStream destination,
long value)
throws java.io.IOException
long to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeLong(java.io.OutputStream destination,
long value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
long to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeShort(java.io.OutputStream destination,
short value)
throws java.io.IOException
short to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeShort(java.io.OutputStream destination,
short value,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
short to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if byteOrder is nulljava.io.IOException - if an I/O error occurspublic static void writeString(java.io.OutputStream destination,
java.lang.String string)
throws java.io.IOException
java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if string is nulljava.io.IOException - if an I/O error occurspublic static void writeString(java.io.OutputStream destination,
java.lang.String string,
java.nio.charset.Charset charset)
throws java.io.IOException
java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if string is nulljava.lang.IllegalArgumentException - if charset is nulljava.io.IOException - if an I/O error occurspublic static void writeUnsignedByte(java.io.OutputStream destination,
int value)
throws java.io.IOException
byte to the given destination.java.lang.IllegalArgumentException - if destination is nulljava.io.IOException - if an I/O error occurspublic static void writeUuid(java.io.OutputStream destination,
java.util.UUID uuid)
throws java.io.IOException
UUID to the given destination using the default (big-endian) byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if uuid is nulljava.io.IOException - if an I/O error occurspublic static void writeUuid(java.io.OutputStream destination,
java.util.UUID uuid,
java.nio.ByteOrder byteOrder)
throws java.io.IOException
UUID to the given destination using the given byte order.java.lang.IllegalArgumentException - if destination is nulljava.lang.IllegalArgumentException - if uuid is nulljava.io.IOException - if an I/O error occurs