JDK-4472113 : (cs) jdk regression: PrintWriter.write() incorrectly writes the characters
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2001-06-20
  • Updated: 2001-08-17
  • Resolved: 2001-07-19
Related Reports
Duplicate :  
Description

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

======================================================================

Comments
EVALUATION Duplicate of 4402886. madbot@eng has already added a "distilled" test to the description of bug 4402886 which is very similar to the one provided here. iris.garcia@eng 2001-07-19
11-06-2004