FileImageInputStreampublic class FileImageInputStream extends ImageInputStreamImpl The FileImageInputStream class implements ImageInputStream and obtains its
input data from a File or RandomAccessFile. |
Fields Summary |
---|
RandomAccessFile | rafThe raf. |
Constructors Summary |
---|
public FileImageInputStream(File f)Instantiates a new FileImageInputStream from the specified File.
if (f == null) {
throw new IllegalArgumentException("f == null!");
}
raf = new RandomAccessFile(f, "r");
| public FileImageInputStream(RandomAccessFile raf)Instantiates a new FileImageInputStream from the specified
RandomAccessFile.
if (raf == null) {
throw new IllegalArgumentException("raf == null!");
}
this.raf = raf;
|
Methods Summary |
---|
public void | close()
super.close();
raf.close();
| public long | length()
try {
return raf.length();
} catch (IOException e) {
return -1L;
}
| public int | read()
bitOffset = 0;
int res = raf.read();
if (res != -1) {
streamPos++;
}
return res;
| public int | read(byte[] b, int off, int len)
bitOffset = 0;
int numRead = raf.read(b, off, len);
if (numRead >= 0) {
streamPos += numRead;
}
return numRead;
| public void | seek(long pos)
if (pos < getFlushedPosition()) {
throw new IndexOutOfBoundsException();
}
raf.seek(pos);
streamPos = raf.getFilePointer();
bitOffset = 0;
|
|