java.io.FileNotFoundException(系统找不到指定的文件)

时间:2023-01-13 08:34:45

    文件需要放在工程目录下.

    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 应该存在于工程目录下,而不是工程的子目录,生成的文件也在工程目录下.