[Advanced-java] Processing text files

David Rosenstrauch david.rosenstrauch at aleri.com
Tue Jun 3 21:43:03 2003


Can't you do:

BufferedReader in = new BufferedReader(new FileReader(inputFile));
String  line;
        while((line=in.readLine()) != null) { 
                out.write(line);                       
        } 


DR


On Tuesday 03 June 2003 04:43 pm, Wesley@lwsi.com wrote:
> I was wondering if anyone knows an easy way to do this.  I am needing to
> take a file that has end of line characters, carriage returns in it, and
> produce a text file that does not have these end of line characters.
> The white space I do need though.  Here is some of the code I have been
> trying, but it does not do what I need
>
> public class fileCramming {
>
>     /** Creates a new instance of fileCramming */
>     public fileCramming() {
>     }
>
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) throws IOException {
>         File inputFile = new File("C:\\hex837F.txt");
>         File outputFile = new File("C:\\hex837FJava.txt");
>
>         FileReader in = new FileReader(inputFile);
>         FileWriter out = new FileWriter(outputFile);
>         int c;
>
>         while((c=in.read()) != -1) {
>             if(c != 10)
>                 out.write(c);
>         }
>         in.close();
>         out.close();
>     }
>
> }
>
>
> Thank you,
>
> Wesley Choate
> LWSI Support Programmer