Reading specific lines
My requirement is to read a text file using java code from a specified line number.
For example:-Text file consists of 10 lakhs of lines,but i want to read the file from some 7500th line to the end.is there any api to skip all these 7500 lines,so that i can go directly to the required line to read the file.
If any solution mail me as soon as possible,Urgent
Spin the wheels...
Not being an expert, but I haven't been able to find an elegant (aka method) to do this. What you could do is just read the first 7500 lines of the file and do nothing with them (with a for loop). Once you are at the correct line to work with, just start processing the way you want. I admit that this may not be the most efficent way to do this, but it should work.
I think CJSLman's is the only way, because, to know where is the 7500th line, you MUST first read 7500 '\n', so you'll end up reading 7500 lines of text to find the '\n' char.... IMHO :)
@Raffaele: thanks for confirming I'm not as crazy as I thought :)
What are "lakhs"?
... 10 lakhs of lines
I think he's talking about in millions. Hundred thousands referred as a lakh, isn't it? In Asian countries it's very common word.
i am very thankful for your response.
I already done in the way what CJSLMAN told.But it will be a performance issue.
Ya Eranga you are right,i am talking about the millions(lakhs)
What performance issues you have, how did you measure that?
Performance issues in the sense,Time measurement
It can be since you have read millions of lines and the way you have implemented your application.