it works but instead of it reverseing the characters i want it to do this "This is a test.” should be reversed to read: “test. a is This”
i want it to do all this in a text file
import java.io.*;
import java.util.*;
public class reverse{
public static void main(String[] args) {
try {
File f = new File("backwards.txt");
FileReader fr = new FileReader(f);
char[] c = new char[(int)f.length()];
char[] cnew = new char[(int)f.length()];
StringBuffer sbuf = new StringBuffer();
fr.read(c,0,(int)f.length());
int len = (int)f.length();
for (int i = 0, j = len - 1; i < len ; i++, j--) {
cnew[i] = c[j];
sbuf.append(cnew[i]);
}
System.out.println(sbuf.toString());
fr.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}