Name: auR10023 Date: 06/20/2001
Method PrintWriter.write(char[], int, int) incorrectly writes the characters.
Following example shows that only 5 characters (instead of 6) appears in the
ByteArrayOutputStream after this method has been performed.
Here is the example
---- t.java ----
import java.io.*;
class t {
public static void main(String args[]) {
char[] streamChars = { (char)0, (char)32, (char)65,
(char)127,(char)128, (char)255 };
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter prnw = new PrintWriter(baos);
prnw.write(streamChars,0,streamChars.length);
prnw.flush();
System.out.println("Resulting length = " + baos.size());
System.out.println("Expected length = " + streamChars.length);
}
}
#java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
#java t
Resulting length = 6
Expected length = 6
#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 t
Resulting length = 5
Expected length = 6
======================================================================