Is there a better [pre-existing optional Java 1.6] solution than creating a streaming file reader class that will meet the following criteria?
- Given an ASCII file of arbitrary large size where each line is terminated by a
\n
- For each invocation of some method
readLine()
read a random line from the file - And for the life of the file handle no call to
readLine()
should return the same line twice
Update:
- All lines must eventually be read
Context: the file's contents are created from Unix shell commands to get a directory listing of all paths contained within a given directory; there are between millions to a billion files (which yields millions to a billion lines in the target file). If there is some way to randomly distribute the paths into a file during creation time that is an acceptable solution as well.