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

java.io.BufferedWriter.write(chars, int, negative) - no exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic



      Name: bb33257 Date: 06/25/98


      In the example below, we attempt to write to a BufferedWriter with a
      negative length field. No exception is thrown, but no write is done
      either.

      This problem causes a JCK test to fail.
      ---------------------------------------------------------------
      import java.io.*;
      public class BWWrite1 {
        public static void main(String[] args) {
          char[] chars = {'a','b','c','d','e','f','g','h'};
          CharArrayWriter caw = new CharArrayWriter();
          BufferedWriter bw = new BufferedWriter(caw);
          try {
            bw.write(chars, chars.length, -14);
            bw.flush();
          }
          catch (Exception e) {
            System.out.println("Exception : " +e);
            System.exit(0);
          }
          System.out.println(caw.toString());
        }
      }
      ======================================================================

            bgomessunw Benedict Gomes (Inactive)
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: