jas2.util
Class FileReaderWithProgressBar
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FileInputStream
-
- jas2.util.FileReaderWithProgressBar
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable
public class FileReaderWithProgressBar extends java.io.FileInputStreamThis 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 toread, 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,BufferedReader,InputStreamReader
-
-
Constructor Summary
Constructors Constructor and Description FileReaderWithProgressBar(java.lang.String fileName, javax.swing.BoundedRangeModel model)Creates a new FileReaderWithProgressBar.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intread()Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.intread(byte[] cbuf)Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.intread(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.longskip(long n)Works just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.
-
-
-
Constructor Detail
-
FileReaderWithProgressBar
public FileReaderWithProgressBar(java.lang.String fileName, javax.swing.BoundedRangeModel model) throws java.io.FileNotFoundExceptionCreates a new FileReaderWithProgressBar.- Parameters:
fileName- the file to readmodel- 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.IOExceptionWorks just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.- Overrides:
readin classjava.io.FileInputStream- Throws:
java.io.IOException- See Also:
FileInputStream,FileInputStream.read()
-
read
public int read(byte[] cbuf) throws java.io.IOExceptionWorks just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.- Overrides:
readin classjava.io.FileInputStream- Throws:
java.io.IOException- See Also:
FileInputStream,FileInputStream.read(byte[])
-
read
public int read(byte[] cbuf, int off, int len) throws java.io.IOExceptionWorks just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.- Overrides:
readin classjava.io.FileInputStream- Throws:
java.io.IOException- See Also:
FileInputStream,FileInputStream.read(byte[], int, int)
-
skip
public long skip(long n) throws java.io.IOExceptionWorks just like the equivalent method in FileInputStream, except that it updates the model to reflect the progress in reading the file.- Overrides:
skipin classjava.io.FileInputStream- Throws:
java.io.IOException- See Also:
FileInputStream,FileInputStream.skip(long)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG