|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.util.IoUtil
public final class IoUtil
Collects some I/O utility functions.
| Method Summary | |
|---|---|
static void |
close(Channel channel)
Closes the channel (safe). |
static void |
close(InputStream in)
Closes the input stream (safe). |
static void |
close(OutputStream out)
Closes the output stream (safe). |
static void |
close(RandomAccessFile randomAccessFile)
Closes the RandomAccessFile (safe). |
static void |
close(Reader reader)
Closes the reader (safe). |
static void |
close(Socket socket)
Closes the socket (safe). |
static void |
close(Writer writer)
Closes the writer (safe). |
static void |
copy(File src,
File dest)
Copies file src to file dest. |
static void |
copy(InputStream in,
OutputStream out)
Reads all data from in and copies it to the out stream. |
static byte[] |
readFully(InputStream in)
Reads all bytes from the input stream in. |
static byte[] |
readFully(InputStream in,
int expectedLength)
Reads expectedLength bytes from the input
stream in. |
static String |
readFully(Reader in)
Reads all characters from the reader in. |
static String |
readFullyNormalizeNewLine(Reader in)
Reads all characters from the reader in and
normalizes newlines to single '\n'. |
static void |
skip(InputStream in,
int bytes)
Ensures that the given number of bytes are skipped from the given input stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void close(InputStream in)
Level.FINE is logged. It's safe to pass a
null reference for the argument.
in - the input stream that should be closed.public static void close(OutputStream out)
Level.FINE is logged. It's safe to pass a
null reference for the argument.
out - the output stream that should be closed.public static void close(Reader reader)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
reader - the reader that should be closed.public static void close(RandomAccessFile randomAccessFile)
Level.FINE
is logged. It's safe to pass a null reference
for the argument.
randomAccessFile - the randomAccessFile that should be closed.public static void close(Writer writer)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
writer - the writer that should be closed.public static void close(Channel channel)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
channel - the channel that should be closed.public static void close(Socket socket)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
socket - the socket that should be closed.
public static byte[] readFully(InputStream in,
int expectedLength)
throws IOException
expectedLength bytes from the input
stream in.
in - the input stream to read from.expectedLength - the expected size.
expectedLength bytes.
IOException - in an I/O error occurs or if the read size is not the
expected size.
public static byte[] readFully(InputStream in)
throws IOException
in.
in - the input stream to read from.
IOException - in an I/O error occurs.
public static String readFully(Reader in)
throws IOException
in.
in - the Reader to read from.
IOException - in an I/O error occurs.
public static String readFullyNormalizeNewLine(Reader in)
throws IOException
in and
normalizes newlines to single '\n'.
in - the Reader to read from.
IOException - in an I/O error occurs.
public static void copy(InputStream in,
OutputStream out)
throws IOException
in - the stream to read.out - the stream to write.
IOException - if an I/O issue occurs.
public static void copy(File src,
File dest)
throws IOException
src - the source file.dest - the destination file.
IOException - if an I/O issue occurs.
public static void skip(InputStream in,
int bytes)
throws IOException
in - the input stream.bytes - the number of bytes to skip.
IOException - if the stream does not support seek,
or if some other I/O error occurs.InputStream.skip(long)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||