// // read from file, echo to standard output // replace new lines with spaces // // uses BufferedReader // import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class RemoveReturns { public static void main( String [] args ) throws IOException { FileReader file = new FileReader( args[0] ); BufferedReader source = new BufferedReader( file ); String line; while ( true ) { line = source.readLine(); if ( line == null ) break; System.out.print( line + " " ); } // ... but now there may be an extraneous trailing space ... } }