// Example of an Exception import java.io.*; class Count { public static int countCharsInFile( String filename ) { int count = -1; try { int ch = 0; FileReader infile = new FileReader( filename ); do { ch = infile.read(); count++; } while (ch != -1); } catch (IOException e) { System.out.println( "IO error:" + e.getMessage() ); } return count; } public static void main( String [] s ) { System.out.println( Count.countCharsInFile( s[0] ) ); } }