|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.netseeker.ejoe.io.IOUtil
public final class IOUtil
Some useful methods for closing io streams, io readers, channels and Selector quitely, as well as methods for non-blocking, semi-blocking and full blocking io read/write operations.
Constructor Summary | |
---|---|
IOUtil()
|
Method Summary | |
---|---|
static java.lang.Object |
adapterDeserialize(SerializeAdapter adapter,
java.io.InputStream in,
boolean compressed)
Invokes a (De)SerializeAdapter for the given Object and handles decompression and buffering |
static void |
adapterSerialize(SerializeAdapter adapter,
java.io.OutputStream out,
java.lang.Object obj,
boolean compressed,
int compressionLevel)
Invokes a SerializeAdapter for the given Object and handles compression and buffering |
static byte |
bBitsToByte(boolean[] bits)
Converts a array of boolean to a byte |
static java.lang.String |
bBitsToSBits(boolean[] bBits)
Converts a array of boolean into a bit-like String representation |
static boolean[] |
byteToBBits(byte b)
Converts a byte to an array of boolean |
static void |
closeQuiet(java.nio.channels.Channel channel)
Tries to close an NIO Channel and handles null values and IOExceptions quietly |
static void |
closeQuiet(java.io.InputStream in)
Tries to close an InputStream and handles null values and IOExceptions quietly |
static void |
closeQuiet(java.io.OutputStream out)
Tries to close an OutputStream and handles null values and IOExceptions quietly |
static void |
closeQuiet(java.io.Reader reader)
Tries to close a Reader and handles null values and IOExceptions quietly |
static void |
closeQuiet(java.nio.channels.Selector selector)
Tries to close a NIO Selector and handles null values and IOExceptions quietly |
static void |
closeQuiet(java.io.Writer out)
Tries to close a Writer and handles null values and IOExceptions quietly |
static java.lang.String |
decodeToString(java.nio.ByteBuffer dataBuf)
|
static java.lang.String |
decodeToString(java.nio.ByteBuffer dataBuf,
java.lang.String charset)
|
static java.nio.ByteBuffer |
encodeToByteBuffer(java.lang.String str)
Converts the given string into a UTF8-encoded ByteBuffer. |
static byte[] |
encodeToBytes(java.lang.String str)
Converts the given string into a UTF8-encoded array of bytes. |
static byte[] |
encodeToBytes(java.lang.String str,
java.lang.String cs)
Converts the given string into a encoded array of bytes. |
static java.nio.ByteBuffer |
readDirect(java.io.InputStream in)
Reads and returns a ByteBuffer from an InputStream |
static boolean[] |
sBitsToBBits(java.lang.String sBits)
Converts a bit-like String representation into an array of boolean |
static void |
setReceiveBufferSize(java.net.Socket socket,
int size)
Set the SO_RCVBUF hint on a connected socket to the size of the data which are expected to be read next time |
static void |
setSendBufferSize(java.net.Socket socket,
int size)
Set the SO_SNDBUF hint on a connected socket to the size of the data which are expected to be written next time |
static void |
writeDirect(java.io.OutputStream out,
java.nio.ByteBuffer buf)
Writes a ByteBuffer directly into an OutputStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IOUtil()
Method Detail |
---|
public static void closeQuiet(java.io.OutputStream out)
out
- The output stream to close quietlypublic static void closeQuiet(java.io.Writer out)
out
- The writer to close quietlypublic static void closeQuiet(java.io.InputStream in)
in
- the input stream to close quietlypublic static void closeQuiet(java.io.Reader reader)
reader
- the reader to close quietlypublic static void closeQuiet(java.nio.channels.Channel channel)
channel
- the channel to close quietlypublic static void closeQuiet(java.nio.channels.Selector selector)
selector
- the selector to close quietlypublic static void adapterSerialize(SerializeAdapter adapter, java.io.OutputStream out, java.lang.Object obj, boolean compressed, int compressionLevel) throws java.lang.Exception
adapter
- out
- obj
- buffered
- compressed
-
java.lang.Exception
public static java.lang.Object adapterDeserialize(SerializeAdapter adapter, java.io.InputStream in, boolean compressed) throws java.lang.Exception
adapter
- in
- buffered
- compressed
-
java.lang.Exception
public static java.nio.ByteBuffer readDirect(java.io.InputStream in) throws java.io.IOException
in
- InputStream from which read a ByteBuffer
java.io.IOException
public static void writeDirect(java.io.OutputStream out, java.nio.ByteBuffer buf) throws java.io.IOException
out
- buf
-
java.io.IOException
public static void setSendBufferSize(java.net.Socket socket, int size) throws java.net.SocketException
socket
- the connected socketsize
- size to set for SO_SNDBUF
java.net.SocketException
public static void setReceiveBufferSize(java.net.Socket socket, int size) throws java.net.SocketException
socket
- the connected socketsize
- size to set for SO_RCVBUF
java.net.SocketException
public static byte[] encodeToBytes(java.lang.String str)
str
-
public static byte[] encodeToBytes(java.lang.String str, java.lang.String cs)
str
- string to be encodedcs
- Charset to use for encoding
public static java.nio.ByteBuffer encodeToByteBuffer(java.lang.String str)
str
-
public static java.lang.String decodeToString(java.nio.ByteBuffer dataBuf)
dataBuf
-
public static java.lang.String decodeToString(java.nio.ByteBuffer dataBuf, java.lang.String charset)
dataBuf
- charset
-
public static boolean[] byteToBBits(byte b)
b
- a byte
public static byte bBitsToByte(boolean[] bits)
bits
- array of booleans representing the bits of a byte
public static boolean[] sBitsToBBits(java.lang.String sBits)
sBits
- bit-like String representation of bits
public static java.lang.String bBitsToSBits(boolean[] bBits)
bBits
- array of boolean to convert
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |