|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.Streams
public class Streams
Static utility methods for processing input and output streams, readers and writers.
| Method Summary | |
|---|---|
static void |
closeInputStream(InputStream in)
Close an input stream. |
static void |
closeOutputStream(OutputStream out)
Close an output stream. |
static void |
closeReader(Reader reader)
Close a reader. |
static void |
closeWriter(Writer writer)
Close a writer. |
static void |
copy(InputStream in,
OutputStream out)
Copies the content of the input stream into the output stream. |
static void |
copy(Reader reader,
Writer writer)
Copies the content of the reader into the writer. |
static String |
getDefaultJavaCharset()
Returns Java's canonical name of the default character set for the system's current default locale. |
static byte[] |
toByteArray(InputStream in)
Returns all the bytes read from the specified input stream as an array. |
static char[] |
toCharArray(InputSource in)
Reads the character content from the specified input source and returns it as a character array. |
static char[] |
toCharArray(InputStream in,
String charset)
Reads the full contents of the specified input stream and returns the characters determined by the specified character set. |
static char[] |
toCharArray(Reader reader)
Reads the full contents of the specified reader and returns it as a character array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String getDefaultJavaCharset()
Note: This method is available in the J2EE version
of Java as javax.mail.internet.getDefaultJavaCharset().
Note 2: For example, the standard English install
of Sun's J2SE 1.4.2 on windows sets the default character set to
"Cp1252", the Windows variant of Latin1.
public static byte[] toByteArray(InputStream in)
throws IOException
This method will block waiting for input.
in - Input stream from which to read bytes.
IOException - If the underlying stream throws an exception
while reading.
public static char[] toCharArray(Reader reader)
throws IOException
reader - Reader from which to get characters.
IOException - If there is an underlying I/O exception.
public static char[] toCharArray(InputStream in,
String charset)
throws IOException
in - The input stream from which to read the bytes.charset - Character set used to convert bytes to characters.
IOException - If there is an underlying I/O exception.
public static char[] toCharArray(InputSource in)
throws IOException
Reader), then that
is used. If it has a specified byte stream (an
InputStream), then that is used. If it has
neither a character nor a byte stream, a byte stream is created
from the system identifier (URL). For both specified and
URL-constructed byte streams, the input source's specified
character set will be used if it is specified.
I/O errors will arise from errors reading from a specified stream, from the character set conversion on a byte stream, or from errors forming or opening a URL specified as a system identifier.
Note that this method does not close the streams within the input source.
in - Input source from which to read.
IOException - If there is an I/O error reading.
public static void copy(Reader reader,
Writer writer)
throws IOException
reader - Reader to copy from.writer - Writer to copy to.
IOException - If there is an underlying I/O exception.
public static void copy(InputStream in,
OutputStream out)
throws IOException
in - Input stream to copy from.out - Output stream to copy to.
IOException - If there is an underlying I/O exception.public static void closeInputStream(InputStream in)
null
without generating an exception.
in - Input stream to close.public static void closeOutputStream(OutputStream out)
null
without generating an exception.
out - Output stream to close.public static void closeReader(Reader reader)
null
without generating an exception.
reader - Reader to close.public static void closeWriter(Writer writer)
null
without generating an exception.
writer - Writer to close.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||