It might be better to store the data you have as floats instead of text. The RandomAccessFile class has a writeFloat(float) method which writes floats to a file using 4 bytes per float. You could use the Float.parseFloat(
String ) method to convert a string into a float.
To access a number in the middle of the file you have to use the
RandomAccessFile.seek(long) method to move the file pointer to the required location. If all the data in your file was written as floats and you wanted to access the nth float you would just have to do
Just remember to take care of the exceptions readFloat() throws.
Go through the
RandomAccesFile javadocs before you start off..
Hope this helps
Sridhar