// Scott DeRuiter 7/18/02 // ReverseAll.java // Will write a file in the reverse. public class ReverseAll { private String stuff, line, reversed; public ReverseAll ( ) { stuff = ""; line = ""; reversed = ""; } public static void main ( String [] args ) { ReverseAll r = new ReverseAll ( ); TextReader inFile; TextWriter outFile; String name1 = "after.txt", name2 = "Reversed.txt"; inFile = new TextReader ( name1 ); outFile = new TextWriter ( name2 ); r.DoTheWork ( inFile, outFile ); } public void DoTheWork ( TextReader inFile, TextWriter outFile ) { while ( !inFile.eof ( ) ) { line = inFile.readLine ( ); if ( line == null ) stuff = stuff + '\n'; else stuff = stuff + line + '\n'; } for ( int i = stuff.length ( ) - 1; i >= 0; i-- ) { char letter = stuff.charAt ( i ); reversed = reversed + letter; } outFile.println ( reversed ); outFile.close ( ); } }