Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2006 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.compoze.collab.util
Class IoUtility

    java.lang.Object
      com.compoze.collab.util.IoUtility

All Implemented Interfaces
  Serializable

    public class IoUtility

extends Object
implements Serializable

This class contains I/O utility methods.

See Also
  Serialized Form

Nested Class Summary
`static class` | `IoUtility.BynameFilenameFilter` Filter a file by its name.

Constructor Summary
`IoUtility()`

Method Summary
`static long` | `copyFile(File sourceFile, File destinationFile)` Copy a source file to a destination file, automatically overwriting the destination.
`static long` | `copyFile(File sourceFile, File destinationFile, boolean bOverwrite)` Copy a source file to a destination file.
`static int` | `copyReaderToWriter(Reader reader, Writer writer)` This copies data from a reader to a writer.
`static int` | `copyReaderToWriter(Reader reader, Writer writer, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput)` This copies data from a reader to a writer.
`static int` | `copyStream(InputStream is, OutputStream os)` This copies all data from an input stream to an output stream.
`static int` | `copyStream(InputStream is, OutputStream os, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput)` This copies data from an input stream to an output stream.
`static Collection` | `findFiles(File baseDir, FilenameFilter filter, boolean bRecursive)` Find a file with the given name underneath a directory.
`static Collection` | `findFiles(File baseDir, String sFileName)` Find a file with the given name underneath a directory.
`static Collection` | `findFiles(File baseDir, String sFilename, boolean bRecursive, boolean bIgnoreCase)` Find a file with the given name underneath a directory.
`static byte[]` | `getBytesFromFile(File file)` This reads an entire file into a byte array.
`static byte[]` | `getBytesFromInputStream(InputStream is)` This reads an entire InputStream into a byte array.
`static InputStream` | `getInputStreamToStringBuffer(StringBuffer buf)` Get an InputStream to a StringBuffer.
`static Object` | `getObjectFromFile(File f)` Gets a serialized object from a `File`.
`static Object` | `getObjectFromFile(String sFile)` Gets a serialized object from a `File`.
`static Object` | `getObjectFromStream(InputStream is)` Gets a serialized object from an `InputStream`.
`static String` | `getStringFromFile(File file)` This reads an entire file into a String.
`static String` | `getStringFromInputStream(InputStream is)` This reads an entire InputStream into a String.
`static String` | `getStringFromInputStream(InputStream is, int iMaxLength)` This reads an entire InputStream into a String.
`static void` | `main(String[] args)` Exerciser.
`static void` | `writeObjectToFile(Object obj, File f)` Writes a serialized object to a file.
`static void` | `writeObjectToFile(Object obj, String sFile)` Writes a serialized object to a file.
`static void` | `writeObjectToStream(Object obj, OutputStream os, boolean bClose)` Writes a serialized object to an `OutputStream`.
`static void` | `writeStringToFile(File file, String s)` This writes a string to a file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IoUtility

    public IoUtility()

Method Detail

### copyStream

    public static int copyStream(InputStream is,
                                 OutputStream os,
                                 int iMaxBytes,
                                 boolean bFlushAndCloseOutput,
                                 boolean bCloseInput)
                          throws IOException

  This copies data from an input stream to an output stream. I/O is buffered if the streams passed in are not already buffered.

  Parameters
    `is` - InputStream to read from
    `os` - OutputStream to write to
    `iMaxBytes` - maximum number of bytes to copy, -1 for no maximum
    `bFlushAndCloseOutput` - flush and close OutputStream after copying
    `bCloseInput` - close InputStream after copying
  Returns
    the number of bytes read
  Throws
    `IOException` - if an i/o error occurred

### copyStream

    public static int copyStream(InputStream is,
                                 OutputStream os)
                          throws IOException

  This copies all data from an input stream to an output stream. I/O is buffered if the streams passed in are not already buffered. The input stream is closed on completion. The output stream is flushed and closed on completion.

  Parameters
    `is` - InputStream to read from
    `os` - OutputStream to write to
  Returns
    the number of bytes copied
  Throws
    `IOException` - if an i/o error occurred

### copyReaderToWriter

    public static int copyReaderToWriter(Reader reader,
                                         Writer writer,
                                         int iMaxBytes,
                                         boolean bFlushAndCloseOutput,
                                         boolean bCloseInput)
                                  throws IOException

  This copies data from a reader to a writer. I/O is buffered if the reader and writer passed in are not already buffered.

  Parameters
    `reader` - reader to read from
    `writer` - writer to write to
    `iMaxBytes` - maximum number of characters to copy, -1 for no maximum
    `bFlushAndCloseOutput` - flush and close writer after copying
    `bCloseInput` - close reader after copying
  Returns
    the number of characters read
  Throws
    `IOException` - if an i/o error occurred

### copyReaderToWriter

    public static int copyReaderToWriter(Reader reader,
                                         Writer writer)
                                  throws IOException

  This copies data from a reader to a writer. I/O is buffered if the reader and writer passed in are not already buffered.

  Parameters
    `reader` - reader to read from
    `writer` - writer to write to
  Returns
    the number of characters read
  Throws
    `IOException` - if an i/o error occurred

### getObjectFromStream

    public static Object getObjectFromStream(InputStream is)
                                      throws IOException,
                                             ClassNotFoundException

  Gets a serialized object from an `InputStream`.

  Parameters
    `is` - the input stream (not `null`)
  Returns
    the object
  Throws
    `IOException`
    `ClassNotFoundException`

### getObjectFromFile

    public static Object getObjectFromFile(File f)
                                    throws IOException,
                                           ClassNotFoundException

  Gets a serialized object from a `File`.

  Parameters
    `f` - the file (not `null`)
  Returns
    the object
  Throws
    `IOException`
    `ClassNotFoundException`

### getObjectFromFile

    public static Object getObjectFromFile(String sFile)
                                    throws IOException,
                                           ClassNotFoundException

  Gets a serialized object from a `File`.

  Parameters
    `sFile` - the filename (not `null`)
  Returns
    the object
  Throws
    `IOException`
    `ClassNotFoundException`

### writeObjectToStream

    public static void writeObjectToStream(Object obj,
                                           OutputStream os,
                                           boolean bClose)
                                    throws IOException

  Writes a serialized object to an `OutputStream`.

  Parameters
    `obj` - the object to write
    `os` - the output stream (not `null`)
    `bClose` - if `true`, close the stream afterwards
  Throws
    `IOException`

### writeObjectToFile

    public static void writeObjectToFile(Object obj,
                                         File f)
                                  throws IOException

  Writes a serialized object to a file.

  Throws
    `IOException`

### writeObjectToFile

    public static void writeObjectToFile(Object obj,
                                         String sFile)
                                  throws IOException

  Writes a serialized object to a file.

  Throws
    `IOException`

### getStringFromFile

    public static String getStringFromFile(File file)
                                    throws IOException

  This reads an entire file into a String.

  Parameters
    `file` - the file to read
  Returns
    a string containing the contents of the entire file
  Throws
    `IOException` - if an i/o error occurred

### getBytesFromFile

    public static byte[] getBytesFromFile(File file)
                                   throws IOException

  This reads an entire file into a byte array.

  Parameters
    `file` - the file to read
  Returns
    a string containing the contents of the entire file
  Throws
    `IOException` - if an i/o error occurred

### getStringFromInputStream

    public static String getStringFromInputStream(InputStream is)
                                           throws IOException

  This reads an entire InputStream into a String.

  Parameters
    `is` - the input stream to read
  Returns
    a string containing the contents of the entire contents of the stream
  Throws
    `IOException` - if an i/o error occurred

### getStringFromInputStream

    public static String getStringFromInputStream(InputStream is,
                                                  int iMaxLength)
                                           throws IOException

  This reads an entire InputStream into a String.

  Parameters
    `is` - the input stream to read
  Returns
    a string containing the contents of the entire contents of the stream
  Throws
    `IOException` - if an i/o error occurred

### getBytesFromInputStream

    public static byte[] getBytesFromInputStream(InputStream is)
                                          throws IOException

  This reads an entire InputStream into a byte array.

  Parameters
    `is` - the input stream to read
  Returns
    a byte array containing the contents of the entire contents of the stream
  Throws
    `IOException` - if an i/o error occurred

### writeStringToFile

    public static void writeStringToFile(File file,
                                         String s)
                                  throws IOException

  This writes a string to a file.

  Parameters
    `file` - the file to write to
    `s` - the string to write
  Throws
    `IOException` - if an i/o error occurred

### getInputStreamToStringBuffer

    public static InputStream getInputStreamToStringBuffer(StringBuffer buf)

  Get an InputStream to a StringBuffer.

  Parameters
    `buf` - the string buffer to get an input stream to
  Returns
    an input stream to the string buffer

### copyFile

    public static long copyFile(File sourceFile,
                                File destinationFile)
                         throws IOException

  Copy a source file to a destination file, automatically overwriting the destination.

  Parameters
    `sourceFile` - the source file
    `destinationFile` - the destination file
  Returns
    the number of bytes that were copied
  Throws
    `IOException` - if an i/o error occurred

### copyFile

    public static long copyFile(File sourceFile,
                                File destinationFile,
                                boolean bOverwrite)
                         throws IOException

  Copy a source file to a destination file.

  Parameters
    `sourceFile` - the source file
    `destinationFile` - the destination file
    `bOverwrite` - if true, overwrite the destination file
  Throws
    `IOException` - if an i/o error occurred, or the destination file exists

### findFiles

    public static Collection findFiles(File baseDir,
                                       String sFileName)
                                throws IOException

  Find a file with the given name underneath a directory.

  Parameters
    `baseDir` - the base directory to search under
    `sFileName` - the file name to search for
  Returns
    the files that were found
  Throws
    `IOException` - if an i/o error occurred

### findFiles

    public static Collection findFiles(File baseDir,
                                       String sFilename,
                                       boolean bRecursive,
                                       boolean bIgnoreCase)
                                throws IOException

  Find a file with the given name underneath a directory.

  Parameters
    `baseDir` - the base directory to search under
    `sFileName` - the file name to search for
    `bRecursive` - if true, search recursively
    `bIgnoreCase` - if true, ignore case when comparing file names
  Returns
    the files that were found
  Throws
    `IOException` - if an i/o error occurred

### findFiles

    public static Collection findFiles(File baseDir,
                                       FilenameFilter filter,
                                       boolean bRecursive)
                                throws IOException

  Find a file with the given name underneath a directory.

  Parameters
    `baseDir` - the base directory to search under
    `sFileName` - the file name to search for
    `bRecursive` - if true, search recursively
    `bIgnoreCase` - if true, ignore case when comparing file names
  Returns
    the files that were found
  Throws
    `IOException` - if an i/o error occurred

### main

    public static void main(String[] args)

  Exerciser.

  Parameters
    `args` - command line arguments

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 BEA Systems, Inc. All Rights Reserved