Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.compoze.util
Class IoUtility

    java.lang.Object
      |
      +--com.compoze.util.IoUtility

All Implemented Interfaces:
  java.io.Serializable

public class IoUtility
extends java.lang.Object
implements java.io.Serializable

This class contains I/O utility methods.

See Also:
  Serialized Form

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

Constructor Summary
`IoUtility()`

Method Summary
`static long` | `copyFile(java.io.File sourceFile, java.io.File destinationFile)` Copy a source file to a destination file, automatically overwriting the destination.
`static long` | `copyFile(java.io.File sourceFile, java.io.File destinationFile, boolean bOverwrite)` Copy a source file to a destination file.
`static int` | `copyReaderToWriter(java.io.Reader reader, java.io.Writer writer)` This copies data from a reader to a writer.
`static int` | `copyReaderToWriter(java.io.Reader reader, java.io.Writer writer, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput)` This copies data from a reader to a writer.
`static int` | `copyStream(java.io.InputStream is, java.io.OutputStream os)` This copies all data from an input stream to an output stream.
`static int` | `copyStream(java.io.InputStream is, java.io.OutputStream os, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput)` This copies data from an input stream to an output stream.
`static java.util.Collection` | `findFiles(java.io.File baseDir, java.io.FilenameFilter filter, boolean bRecursive)` Find a file with the given name underneath a directory.
`static java.util.Collection` | `findFiles(java.io.File baseDir, java.lang.String sFileName)` Find a file with the given name underneath a directory.
`static java.util.Collection` | `findFiles(java.io.File baseDir, java.lang.String sFilename, boolean bRecursive, boolean bIgnoreCase)` Find a file with the given name underneath a directory.
`static byte[]` | `getBytesFromFile(java.io.File file)` This reads an entire file into a byte array.
`static byte[]` | `getBytesFromInputStream(java.io.InputStream is)` This reads an entire InputStream into a byte array.
`static java.io.InputStream` | `getInputStreamToStringBuffer(java.lang.StringBuffer buf)` Get an InputStream to a StringBuffer.
`static java.lang.String` | `getStringFromFile(java.io.File file)` This reads an entire file into a String.
`static java.lang.String` | `getStringFromInputStream(java.io.InputStream is)` This reads an entire InputStream into a String.
`static void` | `main(java.lang.String[] args)` Exerciser.
`static void` | `writeStringToFile(java.io.File file, java.lang.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(java.io.InputStream is,
                                 java.io.OutputStream os,
                                 int iMaxBytes,
                                 boolean bFlushAndCloseOutput,
                                 boolean bCloseInput)
                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### copyStream

    public static int copyStream(java.io.InputStream is,
                                 java.io.OutputStream os)
                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### copyReaderToWriter

    public static int copyReaderToWriter(java.io.Reader reader,
                                         java.io.Writer writer,
                                         int iMaxBytes,
                                         boolean bFlushAndCloseOutput,
                                         boolean bCloseInput)
                                  throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### copyReaderToWriter

    public static int copyReaderToWriter(java.io.Reader reader,
                                         java.io.Writer writer)
                                  throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### getStringFromFile

    public static java.lang.String getStringFromFile(java.io.File file)
                                              throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### getBytesFromFile

    public static byte[] getBytesFromFile(java.io.File file)
                                   throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### getStringFromInputStream

    public static java.lang.String getStringFromInputStream(java.io.InputStream is)
                                                     throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### getBytesFromInputStream

    public static byte[] getBytesFromInputStream(java.io.InputStream is)
                                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### writeStringToFile

    public static void writeStringToFile(java.io.File file,
                                         java.lang.String s)
                                  throws java.io.IOException

  This writes a string to a file.
  Parameters:
    `file` - the file to write to
    `s` - the string to write
  Throws:
    `java.io.IOException` - if an i/o error occurred

### getInputStreamToStringBuffer

    public static java.io.InputStream getInputStreamToStringBuffer(java.lang.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(java.io.File sourceFile,
                                java.io.File destinationFile)
                         throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### copyFile

    public static long copyFile(java.io.File sourceFile,
                                java.io.File destinationFile,
                                boolean bOverwrite)
                         throws java.io.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:
    `java.io.IOException` - if an i/o error occurred, or the destination file exists

### findFiles

    public static java.util.Collection findFiles(java.io.File baseDir,
                                                 java.lang.String sFileName)
                                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### findFiles

    public static java.util.Collection findFiles(java.io.File baseDir,
                                                 java.lang.String sFilename,
                                                 boolean bRecursive,
                                                 boolean bIgnoreCase)
                                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### findFiles

    public static java.util.Collection findFiles(java.io.File baseDir,
                                                 java.io.FilenameFilter filter,
                                                 boolean bRecursive)
                                          throws java.io.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:
    `java.io.IOException` - if an i/o error occurred

### main

    public static void main(java.lang.String[] args)

  Exerciser.
  Parameters:
    `args` - command line arguments

Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.