How to get the last 1 mb of text file data using java code?

I have a 500 mb log file on the server (.txt file). My requirement is that I want only data of only 1 mb. Since we all know that this will cause a problem, if I read the entire file using java code, and this can lead to the problem of using the application. I do not know how to get the latest MB data and have not started coding yet. Anyone please give me an offer?

Thanks Advance,

Rajah

+5
source share
2 answers

for your problem you just need to use a random access file and position the cursor using the seek () method to the end minus 1mb ... Please read the java.io.RandomAccessFile javadoc, especially the seek () comments ...

NTN Jerome

+1

500 ( .txt). 1 .

1 . .

, , java-, .

. , . 500 , , 1 .

, . -, , ?

, , esp .

+1

All Articles