tribble.io
Class StreamCopier

java.lang.Object
  extended by tribble.io.StreamCopier

public class StreamCopier
extends java.lang.Object

Simple stream copying methods.

Since:
2001-01-06
Version:
$Revision: 1.1 $ $Date: 2001/01/06 17:37:36 $
Author:
David R. Tribble, david@tribble.com
Copyright 2001 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.

Field Summary
(package private) static java.lang.String COPYRIGHT
          Embedded copyright notice.
static int DFL_BUFSZ
          Default data copying buffer size (in bytes).
(package private) static java.lang.String REV
          Revision information.
 
Method Summary
static long copy(java.io.InputStream in, java.io.OutputStream out)
          Equivalent to:
copy(in, out, DFL_BUFSZ).
static long copy(java.io.InputStream in, java.io.OutputStream out, int bufsz)
          Copies the contents of an input stream to an output stream.
static long copy(java.io.Reader in, java.io.Writer out)
          Equivalent to:
copy(in, out, DFL_BUFSZ).
static long copy(java.io.Reader in, java.io.Writer out, int bufsz)
          Copies the contents of an input stream to an output stream.
static void main(java.lang.String[] args)
          Test driver.
protected static void run(java.lang.String[] args)
          Runs this class as a program.
protected static void usage()
          Displays a program usage message, then punts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

COPYRIGHT

static final java.lang.String COPYRIGHT
Embedded copyright notice.

See Also:
Constant Field Values

DFL_BUFSZ

public static final int DFL_BUFSZ
Default data copying buffer size (in bytes).

See Also:
Constant Field Values
Method Detail

main

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

Parameters:
args - The command line arguments.
Since:
1.1, 2001-01-06

copy

public static long copy(java.io.InputStream in,
                        java.io.OutputStream out)
                 throws java.io.IOException
Equivalent to:
copy(in, out, DFL_BUFSZ).

Throws:
java.io.IOException
Since:
1.1, 2001-01-06
See Also:
copy(InputStream, OutputStream, int)

copy

public static long copy(java.io.InputStream in,
                        java.io.OutputStream out,
                        int bufsz)
                 throws java.io.IOException
Copies the contents of an input stream to an output stream.

Parameters:
in - The input stream, which is assumed to already be open for reading. This object is synchronized.
out - The output stream, which is assumed to already be open for writing. This object is synchronized.
bufsz - The buffer size to use (in bytes).
Returns:
The number of bytes copied.
Throws:
java.io.IOException - Thrown if a read or write error occurs.
Since:
1.1, 2001-01-06
See Also:
copy(InputStream, OutputStream)

copy

public static long copy(java.io.Reader in,
                        java.io.Writer out)
                 throws java.io.IOException
Equivalent to:
copy(in, out, DFL_BUFSZ).

Throws:
java.io.IOException
Since:
1.1, 2001-01-06
See Also:
copy(Reader, Writer, int)

copy

public static long copy(java.io.Reader in,
                        java.io.Writer out,
                        int bufsz)
                 throws java.io.IOException
Copies the contents of an input stream to an output stream.

Parameters:
in - The input stream, which is assumed to already be open for reading. This object is synchronized.
out - The output stream, which is assumed to already be open for writing. This object is synchronized.
bufsz - The buffer size to use (in bytes).
Returns:
The number of characters copied.
Throws:
java.io.IOException - Thrown if a read or write error occurs.
Since:
1.1, 2001-01-06

run

protected static void run(java.lang.String[] args)
Runs this class as a program. Copies the contents of the standard input to the standard output.

Since:
1.1, 2001-01-06

usage

protected static void usage()
Displays a program usage message, then punts.

This does not return, but calls System.exit(int).

Since:
1.1, 2001-01-06