So your original question wasn't really "I need to write the output of top to a file", it was rather "I need to get the output of top into my java program." In fact, writing it to a file is not the optimal solution (for reasons you are describing). Opening a child top process from Java and piping its output directly to your running program is more along the lines of what you want. I am sure it is possible in Java but I could not tell you how.
In general you should ask what you are really trying to do rather than only asking about what you think the answer is.
And by the way, a 5.8 MB top listing?? How many processes are running on your computer??