Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4472113

(cs) jdk regression: PrintWriter.write() incorrectly writes the characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.0
    • core-libs
    • sparc
    • solaris_2.6



      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

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

            mr Mark Reinhold
            avusunw Avu Avu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: