If I have 1 million lines in a file I cannot jump directly to 50000th line without iterating line by line (which is sequential access). This is my understanding after doing some research in Google.

If this is the case how about Database having 1TB of data where in it searches a row in few seconds. At the end of the day DB also stored in some formatted file with its own metadata.

Can it be possible to implement such a fast string search in a file of 1 million lines of records. What kind of implementation helps us to handle such a large scale of data...

Note Length of Each line may vary from 10 to 100.

Is it possible in Java?