com.anthonyeden.lib.util
Class IOUtilities

java.lang.Object
  extended bycom.anthonyeden.lib.util.IOUtilities

public class IOUtilities
extends java.lang.Object

Useful IO utilities.

Author:
Anthony Eden

Method Summary
static void close(java.io.InputStream s)
          Close the given stream if the stream is not null.
static void close(java.io.OutputStream s)
          Close the given stream if the stream is not null.
static void close(java.io.Reader s)
          Close the given stream if the stream is not null.
static void close(java.io.Writer s)
          Close the given stream if the stream is not null.
static java.lang.String getStringFromReader(java.io.Reader in)
          Read the data from the given reader and return it is a single String.
static byte[] readData(java.io.File file)
          Read the data from the given file into a byte array and return the array.
static byte[] readData(org.apache.commons.vfs.FileObject file)
          Read the data from the given file into a byte array and return the array.
static void writeData(java.io.File file, byte[] data)
          Write the byte array to the given file.
static void writeData(org.apache.commons.vfs.FileObject file, byte[] data)
          Write the byte array to the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public static void close(java.io.InputStream s)
Close the given stream if the stream is not null.

Parameters:
s - The stream

close

public static void close(java.io.Reader s)
Close the given stream if the stream is not null.

Parameters:
s - The stream

close

public static void close(java.io.OutputStream s)
Close the given stream if the stream is not null.

Parameters:
s - The stream

close

public static void close(java.io.Writer s)
Close the given stream if the stream is not null.

Parameters:
s - The stream

readData

public static byte[] readData(java.io.File file)
                       throws java.io.IOException
Read the data from the given file into a byte array and return the array.

Parameters:
file - The file
Returns:
The byte array
Throws:
java.io.IOException

readData

public static byte[] readData(org.apache.commons.vfs.FileObject file)
                       throws java.io.IOException
Read the data from the given file into a byte array and return the array.

Parameters:
file - The file
Returns:
The byte array
Throws:
java.io.IOException

writeData

public static void writeData(java.io.File file,
                             byte[] data)
                      throws java.io.IOException
Write the byte array to the given file.

Parameters:
file - The file to write to
data - The data array
Throws:
java.io.IOException

writeData

public static void writeData(org.apache.commons.vfs.FileObject file,
                             byte[] data)
                      throws java.io.IOException
Write the byte array to the given file.

Parameters:
file - The file to write to
data - The data array
Throws:
java.io.IOException

getStringFromReader

public static java.lang.String getStringFromReader(java.io.Reader in)
                                            throws java.io.IOException
Read the data from the given reader and return it is a single String.

Parameters:
in - The Reader
Returns:
The String
Throws:
java.io.IOException


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.