org.apache.commons.io
Class CopyUtils

java.lang.Object
  extended byorg.apache.commons.io.CopyUtils

public class CopyUtils
extends java.lang.Object

Utility methods for copying data.

Version:
$Id: CopyUtils.java,v 1.4 2003/12/30 16:35:11 jeremias Exp $
Author:
Peter Donald, Jeff Turner, Matthew Hawthorne

Field Summary
private static int DEFAULT_BUFFER_SIZE
          The name says it all.
 
Constructor Summary
CopyUtils()
          Instances should NOT be constructed in standard programming.
 
Method Summary
static void copy(byte[] input, java.io.OutputStream output)
          Copy bytes from a byte[] to an OutputStream.
static void copy(byte[] input, java.io.Writer output)
          Copy and convert bytes from a byte[] to chars on a Writer.
static void copy(byte[] input, java.io.Writer output, java.lang.String encoding)
          Copy and convert bytes from a byte[] to chars on a Writer, using the specified encoding.
static int copy(java.io.InputStream input, java.io.OutputStream output)
          Copy bytes from an InputStream to an OutputStream.
static void copy(java.io.InputStream input, java.io.Writer output)
          Copy and convert bytes from an InputStream to chars on a Writer.
static void copy(java.io.InputStream input, java.io.Writer output, java.lang.String encoding)
          Copy and convert bytes from an InputStream to chars on a Writer, using the specified encoding.
static void copy(java.io.Reader input, java.io.OutputStream output)
          Serialize chars from a Reader to bytes on an OutputStream, and flush the OutputStream.
static int copy(java.io.Reader input, java.io.Writer output)
          Copy chars from a Reader to a Writer.
static void copy(java.lang.String input, java.io.OutputStream output)
          Serialize chars from a String to bytes on an OutputStream, and flush the OutputStream.
static void copy(java.lang.String input, java.io.Writer output)
          Copy chars from a String to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

private static final int DEFAULT_BUFFER_SIZE
The name says it all.

See Also:
Constant Field Values
Constructor Detail

CopyUtils

public CopyUtils()
Instances should NOT be constructed in standard programming.

Method Detail

copy

public static void copy(byte[] input,
                        java.io.OutputStream output)
                 throws java.io.IOException
Copy bytes from a byte[] to an OutputStream.

Parameters:
input - the byte array to read from
output - the OutputStream to write to
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(byte[] input,
                        java.io.Writer output)
                 throws java.io.IOException
Copy and convert bytes from a byte[] to chars on a Writer. The platform's default encoding is used for the byte-to-char conversion.

Parameters:
input - the byte array to read from
output - the Writer to write to
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(byte[] input,
                        java.io.Writer output,
                        java.lang.String encoding)
                 throws java.io.IOException
Copy and convert bytes from a byte[] to chars on a Writer, using the specified encoding.

Parameters:
input - the byte array to read from
output - the Writer to write to
encoding - The name of a supported character encoding. See the IANA Charset Registry for a list of valid encoding types.
Throws:
java.io.IOException - In case of an I/O problem

copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output)
                throws java.io.IOException
Copy bytes from an InputStream to an OutputStream.

Parameters:
input - the InputStream to read from
output - the OutputStream to write to
Returns:
the number of bytes copied
Throws:
java.io.IOException - In case of an I/O problem

copy

public static int copy(java.io.Reader input,
                       java.io.Writer output)
                throws java.io.IOException
Copy chars from a Reader to a Writer.

Parameters:
input - the Reader to read from
output - the Writer to write to
Returns:
the number of characters copied
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output)
                 throws java.io.IOException
Copy and convert bytes from an InputStream to chars on a Writer. The platform's default encoding is used for the byte-to-char conversion.

Parameters:
input - the InputStream to read from
output - the Writer to write to
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(java.io.InputStream input,
                        java.io.Writer output,
                        java.lang.String encoding)
                 throws java.io.IOException
Copy and convert bytes from an InputStream to chars on a Writer, using the specified encoding.

Parameters:
input - the InputStream to read from
output - the Writer to write to
encoding - The name of a supported character encoding. See the IANA Charset Registry for a list of valid encoding types.
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(java.io.Reader input,
                        java.io.OutputStream output)
                 throws java.io.IOException
Serialize chars from a Reader to bytes on an OutputStream, and flush the OutputStream.

Parameters:
input - the Reader to read from
output - the OutputStream to write to
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(java.lang.String input,
                        java.io.OutputStream output)
                 throws java.io.IOException
Serialize chars from a String to bytes on an OutputStream, and flush the OutputStream.

Parameters:
input - the String to read from
output - the OutputStream to write to
Throws:
java.io.IOException - In case of an I/O problem

copy

public static void copy(java.lang.String input,
                        java.io.Writer output)
                 throws java.io.IOException
Copy chars from a String to a Writer.

Parameters:
input - the String to read from
output - the Writer to write to
Throws:
java.io.IOException - In case of an I/O problem