I have written a text file with the following contents: \u0032\u0142o\u017Cy\u0142
Then I have used FileReader und BufferedReader to read the file.
public static void main(String[] args) throws Exception{
FileInputStream fr = new FileInputStream("README.TXT");
BufferedReader br = new BufferedReader(new InputStreamReader(fr,"UTF-8"));
String s="";
while((s=br.readLine())!=null){
System.out.println(s);
}
}
But the output is: \u0032\u0142o\u017Cy\u0142.
When I used
System.out.println("\u0032\u0142o\u017Cy\u0142");
These codes will be parsed and will be shown in the right form.
How can I change my code, so that unicode from the files will also be parsed and shown in the right form?
解决方案
You can use the source code posted here to do unescaping.