• Post Reply Bookmark Topic Watch Topic
  • New Topic

any way to go to end of file  RSS feed

 
Anoop Nath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In java is there any way to go to the end of the file and then move backwards?
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i dont think there is a method to read files backwards so you need to do it yourself (RandomAccessFile, methods seek(), lenght() or FileChannel methods position() and size() or read the full file to memory (e.g. a ArrayList) and then work on that ?). or just use google with this query which gives you the ReverseFileReader as a result. this version reads the whole file into memory (which is a very bad idea if the file is big). maybe you can come up with a solution that only keeps the required lines in memory.
k
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!