/** * SimpleInputFileTester uses SimpleInputFile to read text from a * file and print it in all upper case to the console window. * It also illustrates how to catch exceptions. * * Written: 2/26/03 * * @author Jeff Ondich */ import javabook.*; import java.io.*; class SimpleInputFileTester { public static void main() { MainWindow mw = new MainWindow(); mw.setVisible( true ); System.out.println( "" ); System.out.println( "--------------------------" ); System.out.println( "" ); SimpleInputFile file = new SimpleInputFile(); try { file.openFileChosenByUser( mw ); } catch( IOException exception ) { System.out.println( "Trouble opening " + file.getFileName() ); return; } try { String line = file.readLine(); while( line != null ) { System.out.println( line.toUpperCase() ); line = file.readLine(); } } catch( IOException exception ) { System.out.println( "Trouble reading from " + file.getFileName() ); } } }