// Steve Gribble // 2/14/2006 // // This program will ask the user for the name of a file, and then it // will print (to the console) a version of the file that e e cummings // would have written -- i.e., all in lower case. import java.io.*; import java.util.*; public class EECummings2 { public static void main(String[] args) throws FileNotFoundException { // Ask the user for the file name to open String filename = getInputFile(); // Process the file processFile(filename); } // Asks the user for a filename, and returns it public static String getInputFile() { Scanner console_in = new Scanner(System.in); System.out.print("File name: " ); String filename = console_in.next(); System.out.println(); return filename; } // Processes the file, a line at a time public static void processFile(String name) throws FileNotFoundException { Scanner file_in = new Scanner(new File(name)); while (file_in.hasNextLine()) { processLine(file_in.nextLine()); } } // Processes a line of the file public static void processLine(String text) { String lowertext = text.toLowerCase(); System.out.println(lowertext); } }