|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.io.IoToolbox
Miscellaneous I/O functions.
Details: This class contains a variety of miscellaneous I/O-related utility functions and definitions.
Changes:
Constructor Summary | |
IoToolbox()
|
Method Summary | |
static byte[] |
computeStreamDigest(java.io.InputStream is,
java.lang.String algo)
Computes a message digest from a stream. |
static java.io.LineNumberReader |
getConfigFileReader(java.lang.String name)
Returns reader suitable for parsing config files. |
static java.io.BufferedReader |
getStdinReader()
Creates reader for stdin. |
static int |
peek(java.io.PushbackReader in)
|
static java.lang.String |
preloadStream(java.io.Reader reader,
int size)
Loads entire stream into string. |
static void |
printLines(java.lang.String[] lines)
Prints lines. |
static java.lang.String |
readLine(java.io.Reader r)
|
static void |
unread(java.io.PushbackReader in,
java.lang.String s)
Pushes string onto PushbackReader. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IoToolbox()
Method Detail |
public static byte[] computeStreamDigest(java.io.InputStream is, java.lang.String algo) throws java.io.IOException
Details: computeStreamDigest
computes a message digest for the supplied input stream, closes the stream, and then returns the digest.
The digest name must be one of the standard digest names provided in the Java Security API.
is
- the input streamalgo
- the digest algorithmjava.io.IOException
- if an I/O error occurspublic static void unread(java.io.PushbackReader in, java.lang.String s) throws java.io.IOException
Details: unread pushes the given string (s) onto the given PushbackReader (in).
in
- the PushbackReaders
- the stringjava.io.IOException
- if an I/O error occurspublic static int peek(java.io.PushbackReader in) throws java.io.IOException
public static java.lang.String readLine(java.io.Reader r) throws java.io.IOException
public static void printLines(java.lang.String[] lines)
Details: printLines calls System.out . println()
on each of the strings in the given array (lines). (For example, you can use this to print a program usage summary when your command line program is run without arguments.)
lines
- lines to printpublic static java.io.LineNumberReader getConfigFileReader(java.lang.String name) throws java.io.IOException
Details: getConfigFileReader
returns a LineNumberReader that reads from configuration file whose path is (name). The returned reader automatically trims away Unix-style hashed comments.
name
- path to config filejava.io.IOException
- if an I/O error occurspublic static java.io.BufferedReader getStdinReader() throws java.io.IOException
Details: getStdinReader
returns a BufferedReader
attached to System.in
.
java.io.IOException
- if an I/O error occurspublic static java.lang.String preloadStream(java.io.Reader reader, int size) throws java.io.IOException
Details: preloadStream loads the entire given stream (reader) into a string and returns it. The size parameter offers a hint to this implementation about the total length of the stream, and may be set to 0 if the length of the stream is not known.
reader
- the streamsize
- estimated buffer size neededjava.io.IOException
- if an I/O error occurs
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |