我将FileInputStream更改为BufferedInputStream;
FileOutputStream更改为BufferedOutputStream;
抛出异常后程序依旧无法编译通过,求解!!!谢谢!!!
首先这个是标准异常数据代码:
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try{
- fis = new FileInputStream("xxx.txt");
- fos = new FileOutputStream("yyy.txt");
- int b;
- while((b = fis.read()) != -1){
- fos.write(b);
- }
- }finally{
- try{
- if(fis != null)
- fis.close();
- }finally{
- if(fos != null)
- fos.close();
- }
- }
复制代码
更改后:
- BufferedInputStream bis = null;
- BufferedOutputStream bos = null;
- try{
- bis = new FileInputStream("xxx.txt");
- bos = new FileOutputStream("yyy.txt");
- int b;
- while((b = bis.read()) != -1){
- bos.write(b);
- }
- }finally{
- try{
- if(bis != null)
- bis.close();
- }finally{
- if(bos != null)
- bos.close();
- }
- }
复制代码 |
|