jodd.io
Class StreamUtil

java.lang.Object
  extended by jodd.io.StreamUtil

public class StreamUtil
extends java.lang.Object

Optimized byte and character stream utilities.


Field Summary
static int BUFFER_SIZE
          Buffer size is set to 32 KB.
 
Constructor Summary
StreamUtil()
           
 
Method Summary
static void close(java.io.InputStream in)
          Closes an input stream and releases any system resources associated with this stream.
static void close(java.io.OutputStream out)
          Closes an output stream and releases any system resources associated with this stream.
static void close(java.io.Reader in)
          Closes a character-input stream and releases any system resources associated with this stream.
static void close(java.io.Writer out)
          Closes a character-output stream and releases any system resources associated with this stream.
static boolean compare(java.io.InputStream input1, java.io.InputStream input2)
          Compares the content of two byte streams.
static boolean compare(java.io.Reader input1, java.io.Reader input2)
          Compares the content of two character streams.
static int copy(java.io.InputStream input, java.io.OutputStream output)
          Copies input stream to output stream using buffer.
static int copy(java.io.InputStream input, java.io.OutputStream output, int byteCount)
          Copies specified number of bytes from input stream to output stream using buffer.
static void copy(java.io.InputStream input, java.io.Writer output)
          Copies input stream to writer using buffer.
static void copy(java.io.InputStream input, java.io.Writer output, int byteCount)
          Copies specified number of bytes from input stream to writer using buffer.
static void copy(java.io.InputStream input, java.io.Writer output, java.lang.String encoding)
          Copies input stream to writer using buffer and specified encoding.
static void copy(java.io.InputStream input, java.io.Writer output, java.lang.String encoding, int byteCount)
          Copies specified number of bytes from input stream to writer using buffer and specified encoding.
static void copy(java.io.Reader input, java.io.OutputStream output)
          Copies reader to output stream using buffer.
static void copy(java.io.Reader input, java.io.OutputStream output, int charCount)
          Copies specified number of characters from reader to output stream using buffer.
static void copy(java.io.Reader input, java.io.OutputStream output, java.lang.String encoding)
          Copies reader to output stream using buffer and specified encoding.
static void copy(java.io.Reader input, java.io.OutputStream output, java.lang.String encoding, int charCount)
          Copies specified number of characters from reader to output stream using buffer and specified encoding.
static int copy(java.io.Reader input, java.io.Writer output)
          Copies reader to writer using buffer.
static int copy(java.io.Reader input, java.io.Writer output, int charCount)
          Copies specified number of characters from reader to writer using buffer.
static byte[] readAvailableBytes(java.io.InputStream in)
          Reads all available bytes from InputStream as a byte array.
static byte[] readBytes(java.io.InputStream input)
           
static byte[] readBytes(java.io.InputStream input, int byteCount)
           
static byte[] readBytes(java.io.Reader input)
           
static byte[] readBytes(java.io.Reader input, int byteCount)
           
static byte[] readBytes(java.io.Reader input, java.lang.String encoding)
           
static byte[] readBytes(java.io.Reader input, java.lang.String encoding, int byteCount)
           
static char[] readChars(java.io.InputStream input)
           
static char[] readChars(java.io.InputStream input, int charCount)
           
static char[] readChars(java.io.InputStream input, java.lang.String encoding)
           
static char[] readChars(java.io.InputStream input, java.lang.String encoding, int charCount)
           
static char[] readChars(java.io.Reader input)
           
static char[] readChars(java.io.Reader input, int charCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static int BUFFER_SIZE
Buffer size is set to 32 KB.

Constructor Detail

StreamUtil

public StreamUtil()
Method Detail

close

public static void close(java.io.InputStream in)
Closes an input stream and releases any system resources associated with this stream. No exception will be thrown if an I/O error occurs.


close

public static void close(java.io.OutputStream out)
Closes an output stream and releases any system resources associated with this stream. No exception will be thrown if an I/O error occurs.


close

public static void close(java.io.Reader in)
Closes a character-input stream and releases any system resources associated with this stream. No exception will be thrown if an I/O error occurs.


close

public static void close(java.io.Writer out)
Closes a character-output stream and releases any system resources associated with this stream. No exception will be thrown if an I/O error occurs.


copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output)
                throws java.io.IOException
Copies input stream to output stream using buffer.

Throws:
java.io.IOException

copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output,
                       int byteCount)
                throws java.io.IOException
Copies specified number of bytes from input stream to output stream using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output)
                 throws java.io.IOException
Copies input stream to writer using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output,
                        int byteCount)
                 throws java.io.IOException
Copies specified number of bytes from input stream to writer using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output,
                        java.lang.String encoding)
                 throws java.io.IOException
Copies input stream to writer using buffer and specified encoding.

Throws:
java.io.IOException

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output,
                        java.lang.String encoding,
                        int byteCount)
                 throws java.io.IOException
Copies specified number of bytes from input stream to writer using buffer and specified encoding.

Throws:
java.io.IOException

copy

public static int copy(java.io.Reader input,
                       java.io.Writer output)
                throws java.io.IOException
Copies reader to writer using buffer.

Throws:
java.io.IOException

copy

public static int copy(java.io.Reader input,
                       java.io.Writer output,
                       int charCount)
                throws java.io.IOException
Copies specified number of characters from reader to writer using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.Reader input,
                        java.io.OutputStream output)
                 throws java.io.IOException
Copies reader to output stream using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.Reader input,
                        java.io.OutputStream output,
                        int charCount)
                 throws java.io.IOException
Copies specified number of characters from reader to output stream using buffer.

Throws:
java.io.IOException

copy

public static void copy(java.io.Reader input,
                        java.io.OutputStream output,
                        java.lang.String encoding)
                 throws java.io.IOException
Copies reader to output stream using buffer and specified encoding.

Throws:
java.io.IOException

copy

public static void copy(java.io.Reader input,
                        java.io.OutputStream output,
                        java.lang.String encoding,
                        int charCount)
                 throws java.io.IOException
Copies specified number of characters from reader to output stream using buffer and specified encoding.

Throws:
java.io.IOException

readAvailableBytes

public static byte[] readAvailableBytes(java.io.InputStream in)
                                 throws java.io.IOException
Reads all available bytes from InputStream as a byte array. Uses in.availiable() to determine the size of input stream. This is the fastest method for reading input stream to byte array, but depends on stream implementation of available(). Buffered internally.

Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.InputStream input)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.InputStream input,
                               int byteCount)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.Reader input)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.Reader input,
                               int byteCount)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.Reader input,
                               java.lang.String encoding)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.Reader input,
                               java.lang.String encoding,
                               int byteCount)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.InputStream input)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.InputStream input,
                               int charCount)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.InputStream input,
                               java.lang.String encoding)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.InputStream input,
                               java.lang.String encoding,
                               int charCount)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.Reader input)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.Reader input,
                               int charCount)
                        throws java.io.IOException
Throws:
java.io.IOException

compare

public static boolean compare(java.io.InputStream input1,
                              java.io.InputStream input2)
                       throws java.io.IOException
Compares the content of two byte streams.

Returns:
true if the content of the first stream is equal to the content of the second stream.
Throws:
java.io.IOException

compare

public static boolean compare(java.io.Reader input1,
                              java.io.Reader input2)
                       throws java.io.IOException
Compares the content of two character streams.

Returns:
true if the content of the first stream is equal to the content of the second stream.
Throws:
java.io.IOException


Copyright ©2008 Jodd Team