I am trying to reverse the string. I am reading the string from a field, called abc.txt
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.StringTokenizer;
public class MrText {
    private static final String NEW_LINE_SEPARATOR = System
            .getProperty("line.separator");
    public static void main(String[] args) throws IOException,
            ArrayIndexOutOfBoundsException {
        FileReader input = new FileReader("abc.txt");
        BufferedReader bufRead = new BufferedReader(input);
        StringBuffer rvsWords = new StringBuffer();
        String line;
        line = bufRead.readLine();
        while (line != null) {
            StringTokenizer tok = new StringTokenizer(line);
            String lineReversed = "";
            while (tok.hasMoreElements()) {
                String word = (String) tok.nextElement();
                for (int i = word.length() - 1; i >= 0; i--) {
                    rvsWords.append(word.charAt(i));
                }
            }
            line = bufRead.readLine();
            if (line != null) {
                rvsWords.append(NEW_LINE_SEPARATOR);
            }
        }
        bufRead.close();
        // File outFile = new File("gggggggggggggggggggg.txt");
        FileWriter writer = new FileWriter(outFile);
        writer.write(rvsWords.toString());
        writer.close();
        // System.out.println(rvsWords.toString());
        // rvsWords.setLength(0);
    }
}
text file for input: abc.text contains
IT comp mech civil
output by above code: TI pomc livic hcem
insted i wanyt the output: comp IT civil mech
 
     
     
     
     
     
    