aspose file tools*
The moose likes I/O and Streams and the fly likes Reading text files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading text files" Watch "Reading text files" New topic
Author

Reading text files

mike vessey
Greenhorn

Joined: Nov 09, 2002
Posts: 2
Hi,
I am new to Java and am trying to write a piece of code which will read from a text file and extract words ending with a question mark. I would like to be able to move forwards and backwards through a file.
I've tried using FileReader but the read method only goes forwards. How can I then read the previous character?
Could I read the whole file into a String and then use that instead?
Thanks,
Mike
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
It sounds like you don't really need the full power of random access (although it is an option -- see RandomAccessFile or in Java 1.4 FileChannel).
If you're extracting words, the first (simplest) solution that comes to mind first is to read in the file line by line and then process each line as a String.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading text files