So my program reads in a file and displays it just fine, but when I reverse it, it only displays on one single line.
import java.io.*;
public class palinPractice
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new FileReader("data.txt"));
PrintWriter pr = new PrintWriter(new FileWriter("JCdata.txt"));
String rec;
String temp = "";
while((rec = br.readLine()) != null) // Reads Through
{
System.out.println(rec);
/*for(int i = rec.length()-1;i>=0;i--) // Reverse
{
temp = temp + rec.charAt(i);
}*/
}
System.out.println(temp);
I commented out the reverse statement, but there it is. When I read in the file and display it, it works and it has spaces and new lines where they are supposed to be, but when reversed it displays on one long single line.
Any help would be appreciated.