javax.swing

Class ProgressMonitorInputStream

public class ProgressMonitorInputStream extends FilterInputStream

An input stream with a {@link ProgressMonitor}.

Since: 1.2

UNKNOWN: updated to 1.2

Constructor Summary
ProgressMonitorInputStream(Component component, Object message, InputStream stream)
Creates a new ProgressMonitorInputStream.
Method Summary
voidclose()
Closes the input stream and the associated {@link ProgressMonitor}.
ProgressMonitorgetProgressMonitor()
Returns the {@link ProgressMonitor} used by this input stream.
intread()
Reads an unsigned byte from the input stream and returns it as an int in the range of 0-255.
intread(byte[] data)
Reads bytes from the input stream and stores them in the supplied array, and updates the progress monitor (or closes it if the end of the stream is reached).
intread(byte[] data, int offset, int length)
Reads up to length bytes from the input stream and stores them in the supplied array at the given index, and updates the progress monitor (or closes it if the end of the stream is reached).
voidreset()
Resets the input stream to the point where {@link #mark(int)} was called.
longskip(long length)
Skips the specified number of bytes and updates the {@link ProgressMonitor}.

Constructor Detail

ProgressMonitorInputStream

public ProgressMonitorInputStream(Component component, Object message, InputStream stream)
Creates a new ProgressMonitorInputStream.

Parameters: component the parent component for the progress monitor dialog. message the task description. stream the underlying input stream.

Method Detail

close

public void close()
Closes the input stream and the associated {@link ProgressMonitor}.

Throws: IOException if there is a problem closing the input stream.

getProgressMonitor

public ProgressMonitor getProgressMonitor()
Returns the {@link ProgressMonitor} used by this input stream.

Returns: The progress monitor.

read

public int read()
Reads an unsigned byte from the input stream and returns it as an int in the range of 0-255. Returns -1 if the end of the stream has been reached. The progress monitor is updated.

Returns: int

Throws: IOException if there is a problem reading the stream.

read

public int read(byte[] data)
Reads bytes from the input stream and stores them in the supplied array, and updates the progress monitor (or closes it if the end of the stream is reached).

Parameters: data the data array for returning bytes read from the stream.

Returns: The number of bytes read, or -1 if there are no more bytes in the stream.

Throws: IOException if there is a problem reading bytes from the stream.

read

public int read(byte[] data, int offset, int length)
Reads up to length bytes from the input stream and stores them in the supplied array at the given index, and updates the progress monitor (or closes it if the end of the stream is reached).

Parameters: data the data array for returning bytes read from the stream. offset the offset into the array where the bytes should be written. length the maximum number of bytes to read from the stream.

Returns: The number of bytes read, or -1 if there are no more bytes in the stream.

Throws: IOException if there is a problem reading bytes from the stream.

reset

public void reset()
Resets the input stream to the point where {@link #mark(int)} was called.

Throws: IOException TODO

skip

public long skip(long length)
Skips the specified number of bytes and updates the {@link ProgressMonitor}.

Parameters: length the number of bytes to skip.

Returns: The actual number of bytes skipped.

Throws: IOException if there is a problem skipping bytes in the stream.