Java output file doesnt recognise \n as linebreak
- by oderebek
for a Java project for a University Class I have a method that saves ASCII images as a uniline string and another method called toString rebuilds this ASCII image and returns as a string. When I run my program on the Eclipse my output looks on console alright and multiline, and there are line breaks where they should be. But when I run it with the command line with a redirected outputfile
java myprogram < input output
the text in the output is uniline without line breaks
Here is the code of the method
public String toString(){
String output = "";
for(int i=0; i<height; i++){
output=output+image.substring(i*width, i*width+width)+"\n";
}
return output;
}
What should I do so I can get a multiline output text file