文件需要放在工程目录下.
eg:
public class Example{
public static void main(String[] args) throws Exception {
BufferedReader bufferedReader = new BufferedReader(new FileReader("zj.txt"));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("jz.txt"));
String str;
while ( (str=bufferedReader.readLine()) != null) {
bufferedWriter.write(str);
}
bufferedReader.close();
bufferedWriter.close();
}
}
zj.txt 应该存在于工程目录下,而不是工程的子目录,生成的文件也在工程目录下.