Lets say I have a file like this:

'Line 1'
"Line 2"
"Line 3"

Recommended Answers

All 3 Replies

You have no choice but to read the file from the start until you get to the line you want.

(Unless the lines are all the same fixed length, in which case you can use a random access file and seek directly to the calculated offset of the desired line)

Member Avatar

Read lines into an arrayList, access the arrayList.

Read the text file from BufferReader and check String contains from your search value...
Its a easy way to read the text file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.