-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2beta3
-
sparc
-
solaris_2.5
-
Verified
Name: saC57035 Date: 11/11/97
Method java.io.LineNumberInpupStream.skip(long n) does not recognize
CR/LF pair as _one_ EOL character.
According to the specs, method read of LineNumberInputStream
converts CR/LF pairs into LF character. Method skip should
call read to skip required number of bytes, thus counting that pair as
one character.
The test below reveals incorrect behaviour:
------- SkipTest.java -------------
import java.io.*;
public class SkipTest {
public static void main( String argv[] ) {
byte[] data = {12,13,10,23,11};
LineNumberInputStream in = new LineNumberInputStream(new ByteArrayInputStream(data));
try {
long skipped = in.skip(3); // skip 3 bytes
System.out.println("Skipped: "+skipped);
System.out.println("next byte: "+in.read());
}
catch(Throwable e) // Test no exceptions are thrown
{ System.out.println( "Unexpected "+e+" thrown" );
}
}
}
---------- output ------------------
134% java SkipTest
Skipped: 3
next byte: 23
------------------------------------
Next byte should be 11 in this case.
Please note that the regression took place in most recent (as of today)
build only - JDK 1.2S. Previous builds as well as JDK 1.1.X builds don't
have this problem.
======================================================================