| public static void main(String[] args) { 
 ByteArrayInputStream bis = new ByteArrayInputStream("abcedf".getBytes());
 
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
 int ch = 0;
 
 while((ch=bis.read())!=-1){
 bos.write(ch);
 }
 
 System.out.println(bos.toString());
 bis.close();
 bos.close();
 }
 
 这段代码演示了ByteArrayInputStream的流对象,很简单,但是就是在操作流的关闭的时候需要对异常进行处理, 这个是怎么回事?一般我们在操作流对象的时候,都会有关流的习惯,这个流不关会不会造成资源的浪费?
 
 
 |