wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes how to reverse the contents of a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to reverse the contents of a text file" Watch "how to reverse the contents of a text file" New topic
Author

how to reverse the contents of a text file

aakash bose
Greenhorn

Joined: Jun 10, 2013
Posts: 4

hi guyz!! I want to read the characters from a text file and print each character in reverse order. e.g
if the file SAMPLE.txt is:
abc
def
ghi

my output should be
ihj
fed
cba


K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2230
    
    7

You may want to check the JavaRanch jr.jar javadoc Str class. http://www.javaranch.com/doc/com/javaranch/common/Str.html

Or other API that does string manipulation rather than writing your own.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to reverse the contents of a text file
 
Similar Threads
Radix Sort
Java: Convert a binary file to "text" and back again.
String reversal program
calling a button from utility file
Reading a file in reverse order