• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a file in reverse order

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

How to read the file using BufferedReader in reverse oreder.
please give the example code.

Thanks.
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two choices for this.

either you read the content of the whole file into a StringBuffer (via a String) and then reverse the StringBuffer.

The second option is to read the file one character at a time in reverse order with the help of RandomAccessFile object which is not in the objectives of SCJP so I don't think it must be discussed here....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic