- import java.io.*;
- class CopyTextByBuf
- {
- public static void main(String[] args)
- {
- BufferedReader bufr = null;
- BufferedWriter bufw = null;
- try
- {
- bufr = new BufferedReader(new FileReader("Text_IO.java"));
- bufw = new BufferedWriter(new FileWriter("b.txt"));
- String line = null;
- while((line=bufr.readLine())!=null)
- {
- bufw.write(line);
- bufw.newLine();
- bufw.flush();
- }
- }
- catch (IOException e)
- {
- throw new RuntimeException("读写失败");
- }
- finally
- {
- try
- {
- if(bufr!=null)
- bufr.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("读取关闭失败");
- }
- try
- {
- if(bufw!=null)
- bufw.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("写入关闭失败");
- }
- }
- }
- }
复制代码
为什么这段代码一直报这个异常?可以编译、但是就是复制不了。源文件也有啊。郁闷~~高手copy代码看看吧、
|
|