// Read a file containing rectangle paint commands // and draw them in a Drawing Panel // See RectanglePainter.java for final solution // Step 2: Read and process one rectangle description // using a method that just prints it // Use nextLine to scan file import java.util.*; import java.io.*; public class Paint2 { public static void main(String[] args) throws FileNotFoundException { String fileName = getFileName(); Scanner fileScan = new Scanner(new File(fileName)); String line = fileScan.nextLine(); Scanner lineScan = new Scanner(line); int width = lineScan.nextInt(); int height = lineScan.nextInt(); System.out.println("width: " + width + ", " + height); line = fileScan.nextLine(); processLine(line); } public static String getFileName() { Scanner console = new Scanner(System.in); System.out.print("File name: "); return console.next(); } public static void processLine(String line) { System.out.println(line); } }