Originally Posted by
ineedahero
Naw, I don't have any of that.
I thought Random Access Files took care of everything automatically.
No. Technically every file can be random accessed, if you have the appropriate API (and in Java there is java.io.RandomAccessFile). But this doesn't mean that all file types are appropriate for random access!
For a "pure" text file it has no sense the random access, you can't say "move at line 1234", because there's no "indexing" of lines, you don't know the absolute offset of line 1234. You have to read sequentially all lines until the end of file or until you find a line that you want.
So, if you have a "text" file, you can read on "lines" at least in two ways:
1) java.util.Scanner, with hasNextLine() / nextLine()
2) java.io.BufferedReader, with readLine(). Note: BufferedReader cannot be used alone for a file, you need a FileReader or a FileInputStream+InputStreamReader.