wood burning stoves
The moose likes I/O and Streams and the fly likes Java BufferedReader and BufferedWriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Java BufferedReader and BufferedWriter" Watch "Java BufferedReader and BufferedWriter" New topic

Java BufferedReader and BufferedWriter

harrell collins

Joined: Mar 08, 2006
Posts: 22
I am writing a program that uses BufferedReader to Read through a postscript file and number the lines. So that I can write a postscript instruction at specific line numbers. However, I am encountering an error when I try to use BufferedWriter. I have tried closing the BufferedReader to no avail. Can anyone share insight of code that will help with this. Also can anyone recommend a way to search through a directory for files using a wildcard e.g "/e3/MAILING/1028.*". any insight or help would be appreciated.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
In this code snippet I take a source file and while I read it with a LineNumberReader, when I process a particular line, I do something special with the text (in this case I reverse it). While I read the file, I copy it to a temporary file. At the end I replace the original file with the new temporary file.

Another approach is to use a memory stream to store temporary information, before writing back to file.

Edwin Dalorzo.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
As for the listing files in a directory you can use the java.io.FileFilter or the java.io.FilenameFilter.

Look at this code snippet.

Edwin Dalorzo.
I agree. Here's the link: http://aspose.com/file-tools
subject: Java BufferedReader and BufferedWriter
It's not a secret anymore!