I have a .dat file which has some 100 odd lines,i want to extract some 50 odd lines and put them in some memory (not a file) and the rest of the content in some other memory,like a buffer (again not in a file).The final output should have both the contents but some text must be inserted between them.There's also a field in .dat file which needs to be extracted and printed.
--> the 17 digit register no has to be extracted and printed ---
<tr style="FONT-FAMILY: Verdana; border: 1px #ffab00 solid; padding-right: 4px; empty-cells: show; "><td> Register no:12345678901234567</td></tr>
So, what exactly is your question: how to read a file (is it a text file that you want to read line by line?), how to find a specific piece of data in a string, ...? Have you written some code already yourself, and if yes, then where exactly do you get stuck - does it compile or not, does it run or not, do you get error messages? If yes, then what are the error messages? If you don't get an error message but it doesn't produce the output you expect, then how does what it actually does differ from what you expected?
Reading a file line by line is easy with a BufferedReader; see this example.
Searching for text in a string can be done with the methods in the String class (lookup the API documentation), or with regular expressions; see the java.util.regex package for that.
You'll most likely want to use a collection class such as ArrayList to keep the data in memory.
swanand hhhhhh wrote:Please reply fast,i need it urgently.