-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.4.0
-
generic
-
generic
Name: vpR10011 Date: 07/18/2001
Specification of the class javax.imageio.stream.FileImageOutputStream says:
"public int read() throws IOException
...
Reads a single byte from the stream and returns it as an integer between 0
and 255. If the end of the stream is reached, -1 is returned.
The bit offset within the stream is reset to zero before the read occurs.
Returns: a byte value from the stream, as an int, or -1 to indicate EOF.
Throws: IOException - if an I/O error occurs."
Specification of the method javax.imageio.stream.FileImageInputStream.read()
is the same.
If the stream position was set beyond the end of the file by seek(long) method
and the value of this stream position is very large then the method read()
throws IOException under WindowsNT.
Under Solaris method read() returns -1.
To reproduce this bug run the following test.
"tmp" is file from current directory.
---------------------test.java--------------
import java.io.*;
import javax.imageio.stream.*;
public class test {
public static void main(String[] argv) {
int t;
System.out.println("FileImageInputStream");
try {
RandomAccessFile raf = new RandomAccessFile("tmp","rw");
FileImageInputStream fiis = new FileImageInputStream(raf);
fiis.seek(Long.MAX_VALUE);
System.out.println("file position: "+ fiis.getStreamPosition());
t = fiis.read();
System.out.println("read() = " + t);
fiis.close();
} catch (Exception e) {
System.out.println(e);
}
System.out.println("");
System.out.println("FileImageOutputStream");
try {
RandomAccessFile raf1 = new RandomAccessFile("tmp","rw");
FileImageOutputStream fios = new FileImageOutputStream(raf1);
fios.seek(Long.MAX_VALUE);
System.out.println("file position: "+ fios.getStreamPosition());
t = fios.read();
System.out.println("read() = " + t);
fios.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
----------------------log under Solaris--------------------
% javac test.java
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
% java test
ja14 -classpath . test
FileImageInputStream
file position: 9223372036854775807
read() = -1
FileImageOutputStream
file position: 9223372036854775807
read() = -1
---------------------log under WindowsNT-------------------
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
% java test
FileImageInputStream
file position: 9223372036854775807
java.io.IOException: The parameter is incorrect
FileImageOutputStream
file position: 9223372036854775807
java.io.IOException: The parameter is incorrect
-----------------------------------------------------------
======================================================================