All Packages Class Hierarchy This Package Previous Next Index
Class com.oroinc.io.Util
java.lang.Object
|
+----com.oroinc.io.Util
- public final class Util
- extends Object
The Util class cannot be instantiated and stores short static convenience
methods that are often quite useful.
Copyright © 1997 Original Reusable Objects, Inc.
All rights reserved.
- See Also:
- CopyStreamException, CopyStreamListener, CopyStreamAdapter
-
DEFAULT_COPY_BUFFER_SIZE
- The default buffer size used by copyStream
and copyReader .
-
copyReader(Reader, Writer)
- Same as
copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
-
copyReader(Reader, Writer, int)
- Copies the contents of a Reader to a Writer using a
copy buffer of a given size.
-
copyReader(Reader, Writer, int, long, CopyStreamListener)
- Copies the contents of a Reader to a Writer using a
copy buffer of a given size and notifies the provided
CopyStreamListener of the progress of the copy operation by calling
its bytesTransferred(long, int) method after each write to the
destination.
-
copyStream(InputStream, OutputStream)
- Same as
copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
-
copyStream(InputStream, OutputStream, int)
- Copies the contents of an InputStream to an OutputStream using a
copy buffer of a given size.
-
copyStream(InputStream, OutputStream, int, long, CopyStreamListener)
- Copies the contents of an InputStream to an OutputStream using a
copy buffer of a given size and notifies the provided
CopyStreamListener of the progress of the copy operation by calling
its bytesTransferred(long, int) method after each write to the
destination.
DEFAULT_COPY_BUFFER_SIZE
public static final int DEFAULT_COPY_BUFFER_SIZE
- The default buffer size used by copyStream
and copyReader . It's value is 1024.
copyStream
public static final long copyStream(InputStream source,
OutputStream dest,
int bufferSize,
long streamSize,
CopyStreamListener listener) throws CopyStreamException
- Copies the contents of an InputStream to an OutputStream using a
copy buffer of a given size and notifies the provided
CopyStreamListener of the progress of the copy operation by calling
its bytesTransferred(long, int) method after each write to the
destination. If you wish to notify more than one listener you should
use a CopyStreamAdapter as the listener and register the additional
listeners with the CopyStreamAdapter.
The contents of the InputStream are
read until the end of the stream is reached, but neither the
source nor the destination are closed. You must do this yourself
outside of the method call. The number of bytes read/written is
returned.
- Parameters:
- source - The source InputStream.
- dest - The destination OutputStream.
- bufferSize - The number of bytes to buffer during the copy.
- streamSize - The number of bytes in the stream being copied.
Should be set to CopyStreamEvent.UNKNOWN_STREAM_SIZE if unknown.
- listener - The CopyStreamListener to notify of progress. If
this parameter is null, notification is not attempted.
- Throws: CopyStreamException
- If an error occurs while reading from the
source or writing to the destination. The CopyStreamException
will contain the number of bytes confirmed to have been
transferred before an
IOException occurred, and it will also contain the IOException
that caused the error. These values can be retrieved with
the CopyStreamException getTotalBytesTransferred() and
getIOException() methods.
copyStream
public static final long copyStream(InputStream source,
OutputStream dest,
int bufferSize) throws CopyStreamException
- Copies the contents of an InputStream to an OutputStream using a
copy buffer of a given size. The contents of the InputStream are
read until the end of the stream is reached, but neither the
source nor the destination are closed. You must do this yourself
outside of the method call. The number of bytes read/written is
returned.
- Parameters:
- source - The source InputStream.
- dest - The destination OutputStream.
- Returns:
- The number of bytes read/written in the copy operation.
- Throws: CopyStreamException
- If an error occurs while reading from the
source or writing to the destination. The CopyStreamException
will contain the number of bytes confirmed to have been
transferred before an
IOException occurred, and it will also contain the IOException
that caused the error. These values can be retrieved with
the CopyStreamException getTotalBytesTransferred() and
getIOException() methods.
copyStream
public static final long copyStream(InputStream source,
OutputStream dest) throws CopyStreamException
- Same as
copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
copyReader
public static final long copyReader(Reader source,
Writer dest,
int bufferSize,
long streamSize,
CopyStreamListener listener) throws CopyStreamException
- Copies the contents of a Reader to a Writer using a
copy buffer of a given size and notifies the provided
CopyStreamListener of the progress of the copy operation by calling
its bytesTransferred(long, int) method after each write to the
destination. If you wish to notify more than one listener you should
use a CopyStreamAdapter as the listener and register the additional
listeners with the CopyStreamAdapter.
The contents of the Reader are
read until its end is reached, but neither the source nor the
destination are closed. You must do this yourself outside of the
method call. The number of characters read/written is returned.
- Parameters:
- source - The source Reader.
- dest - The destination writer.
- bufferSize - The number of characters to buffer during the copy.
- streamSize - The number of characters in the stream being copied.
Should be set to CopyStreamEvent.UNKNOWN_STREAM_SIZE if unknown.
- listener - The CopyStreamListener to notify of progress. If
this parameter is null, notification is not attempted.
- Returns:
- The number of characters read/written in the copy operation.
- Throws: CopyStreamException
- If an error occurs while reading from the
source or writing to the destination. The CopyStreamException
will contain the number of bytes confirmed to have been
transferred before an
IOException occurred, and it will also contain the IOException
that caused the error. These values can be retrieved with
the CopyStreamException getTotalBytesTransferred() and
getIOException() methods.
copyReader
public static final long copyReader(Reader source,
Writer dest,
int bufferSize) throws CopyStreamException
- Copies the contents of a Reader to a Writer using a
copy buffer of a given size. The contents of the Reader are
read until its end is reached, but neither the source nor the
destination are closed. You must do this yourself outside of the
method call. The number of characters read/written is returned.
- Parameters:
- source - The source Reader.
- dest - The destination writer.
- bufferSize - The number of characters to buffer during the copy.
- Returns:
- The number of characters read/written in the copy operation.
- Throws: CopyStreamException
- If an error occurs while reading from the
source or writing to the destination. The CopyStreamException
will contain the number of bytes confirmed to have been
transferred before an
IOException occurred, and it will also contain the IOException
that caused the error. These values can be retrieved with
the CopyStreamException getTotalBytesTransferred() and
getIOException() methods.
copyReader
public static final long copyReader(Reader source,
Writer dest) throws CopyStreamException
- Same as
copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
All Packages Class Hierarchy This Package Previous Next Index