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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      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

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: