This is my code, I am trying to write a text file replacing "Up" and "Right" with ↑ and →. The problem is that the text file output is: "→ ↑"(this is not what i wanted) and the console output is "↑ →".
private static void print(String t){
File log = new File("a.txt");
String raw = t;
raw = raw.replaceAll("Up", " \u2191 "); //↑
raw = raw.replaceAll("Right", " \u2192 "); //→
try{
FileWriter fileWriter = new FileWriter(log, true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write(raw + "\n");
System.out.println(raw + "\n")
bufferedWriter.close();
}catch(IOException e) {}
}
I think it may be an encoding error, but I dont know how to fix it.