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());
}
}
======================================================================
- duplicates
-
JDK-4127657 read(byte[], int, int) in xxxReader can throw undocumented exceptions
-
- Closed
-