本帖最后由 jing迪 于 2014-1-8 15:08 编辑
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- public class BufferedDemo {
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new FileReader("fw2.txt"));
- BufferedWriter bw = new BufferedWriter(new FileWriter("fw7.txt"));
-
- char[] chs = new char[1024];
- int len = 0;
- while((len=br.read(chs))!=1){
- bw.write(chs,0,len);
- bw.flush();
- }
- bw.close();
- br.close();
- }
- }
复制代码
这个代码报错
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.io.BufferedWriter.write(BufferedWriter.java:178)
at cn.itcast_03.BufferedDemo.main(BufferedDemo.java:19)
为啥呀?????? |