/* Parse a text file To use this program, specify the name of the source file and the destination file. For example, to copy a file called FIRST.TXT to a file called SECOND.TXT, use the following command line. java ParseFile FIRST.TXT SECOND.TXT */ import java.io.*; import java.util.StringTokenizer; class ParseFile { public static void main( String args[] ) throws IOException { int i; FileInputStream fin; FileOutputStream fout; try { fin = new FileInputStream( args[0] ); fout = new FileOutputStream( args[1] ); } catch( FileNotFoundException e ) { System.out.println( "File Not Found" ); return; } catch( IOException e ) { System.out.println( "Error Opening Output File" ); return; } catch( ArrayIndexOutOfBoundsException e ) { System.out.println( "Usage: ParseFile From To" ); return; } // Parse File try { do { i = fin.read(); if( i != -1 ) System.out.print( (char) i ); if( i != -1 ) fout.write( i ); } while( i != -1 ); } catch( IOException e ) { System.out.println( "File Error" ); } fin.close(); fout.close(); } }