I am currently working in a lab in the cpe class, and we need to create a simple program that scans strings from a TXT file and prints them in another .txt file. So far I have the main program, but my exception continues to receive a throw, although I have all the necessary files. Can someone help me debug?
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.");
}
}
}
Mike source
share