while writing a null array after closing the stream it should throw Null pointer exception.
But it throws IO Exception
Error output:
------------
java.io.IOException: Stream is closed
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:130)
at IoStream.main(IoStream.java:10)
recreate it using the below testcase.
import java.io.*;
public class Test{
public static void main(String [] args){
try
{ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("out.txt")); out.close(); out.write(null,0,1); out.close(); }
catch(NullPointerException npe)
{ System.out.println("TEST PASSED"); }
catch(IOException e )
{ e.printStackTrace(); }
catch(Exception e ){ e.printStackTrace(); }
}
}