jas.util
Class FileReaderWithProgressBar

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FileInputStream
              |
              +--jas.util.FileReaderWithProgressBar

public class FileReaderWithProgressBar
extends java.io.FileInputStream

This class should be used when you want to have a BoundedRangeModel display the progress as a file is being opened. The model is updated with each call to read, so it is ideally used in a BufferedReader where the stream is read in buffer-sized amounts. That way, the model updates only when the buffer is filled. For example, you might use it like this:
BufferedReader input = new BufferedReader(new InputStreamReader(new FileReaderWithProgressBar(name, model)));

See Also:
BoundedRangeModel, java.io.BufferedReader, java.io.InputStreamReader

Constructor Summary
FileReaderWithProgressBar(java.lang.String fileName, javax.swing.BoundedRangeModel model)
          Creates a new FileReaderWithProgressBar.
 
Method Summary
 int read()
          Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
 int read(byte[] cbuf)
          Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
 int read(byte[] cbuf, int off, int len)
          Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
 long skip(long n)
          Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
 
Methods inherited from class java.io.FileInputStream
available, close, finalize, getFD
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReaderWithProgressBar

public FileReaderWithProgressBar(java.lang.String fileName,
                                 javax.swing.BoundedRangeModel model)
                          throws java.io.FileNotFoundException
Creates a new FileReaderWithProgressBar.
Parameters:
fileName - the file to read
model - the BoundedRangeModel to update
Throws:
java.io.FileNotFoundException - thrown from the constructor of FileInputStream
See Also:
BoundedRangeModel
Method Detail

read

public int read()
         throws java.io.IOException
Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
Overrides:
read in class java.io.FileInputStream
See Also:
FileInputStream, FileInputStream.read()

read

public int read(byte[] cbuf)
         throws java.io.IOException
Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
Overrides:
read in class java.io.FileInputStream
See Also:
FileInputStream, FileInputStream.read(byte[])

read

public int read(byte[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
Overrides:
read in class java.io.FileInputStream
See Also:
FileInputStream, FileInputStream.read(byte[], int, int)

skip

public long skip(long n)
          throws java.io.IOException
Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
Overrides:
skip in class java.io.FileInputStream
See Also:
FileInputStream, FileInputStream.skip(long)