package class9_1_WritingTextFiles_start; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.Paths; import java.util.Scanner; public class CarWriter { public static void main(String[] args) { System.out.println("This [will be] a command-line car processor. (For offline " + "simulation)"); Scanner in = new Scanner(System.in); System.out.print("Filename: "); String filename = in.nextLine(); try (PrintWriter printWriter = new PrintWriter( Paths.get(filename).toFile())){ int x = 5; int y = 0; printWriter.println(x+" "+y); printWriter.print(""); } catch (FileNotFoundException e) { System.out.println("Could not open the file: "+filename); // e.printStackTrace(); // FOR DEBUGGING ONLY } catch (IOException e) { System.out.println("Error while reading file: "+filename); } } }