現在、cpeクラスのラボで作業しており、.txtファイルから文字列をスキャンして別の.txtファイルに出力する簡単なプログラムを作成する必要があります。これまでのところ、基本的なプログラムを作成しましたが、必要なファイルはすべて揃っていますが、例外が発生し続けます。誰かが私がデバッグするのを手伝ってもらえますか?
import java.io.*;
import java.util.*;
public class FileIO {
public static void main(String args[]) {
try {
File input = new File("input");
File output = new File("output");
Scanner sc = new Scanner(input);
PrintWriter printer = new PrintWriter(output);
while(sc.hasNextLine()) {
String s = sc.nextLine();
printer.write(s);
}
}
catch(FileNotFoundException e) {
System.err.println("File not found. Please scan in new file.");
}
}
}