i think it is not advisable to store the thousands of line in the memory using Buffering, what is the best API in java, that i can store it in a temporary txt,.
or how can i edit the text file, let say i want to edit directly to line number 100?
If you can't store the contents in memory the best option is to use a temporary file. In short:
1) create a temporary file (perhaps using File.createTempFile)
2) read a line from the original file, modify as needed, write it to the temporary file
3) repeat step 2) until done
4) delete the original file
5) rename the temporary file to the original file (renameTo will also move files if the parent folder is different)
Not like this. First of all, you'll need the File returned by File.createTempFile("temporary","bh",file), as this is the file you're going to write to, not the original file. Haven't you read my first post? It basically includes the entire algorithm in normal words; all you need to do is translate it into code (hint: steps 2 and 3 are a loop).