This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a file in reverse order  RSS feed

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 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: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!