I'm reading a file which contains unicode escape sequence among the text, here the example:
\u201c@hannah_hartzler: In line for the gate keeper! @nerk97 @ShannonWalkup\u201d\ud83d\ude0d\ud83d\ude0d\ud83d\ude0d\ud83d\ude0d\u2764\u2764\u2764
When I'm reading it with a BufferedReader and write it back to another file with FileWriter the text become like this :
“@hannah_hartzler: In line for the gate keeper! @nerk97 @ShannonWalkupâ€ðŸ˜ðŸ˜ðŸ˜ðŸ˜â¤â¤â¤
due, to the UTF-8 encoding, but what I want to have is:
“@hannah_hartzler: In line for the gate keeper! @nerk97 @ShannonWalkup”😍😍😍😍❤❤❤
My question is, how to read and write correctly lines of text, in order to have printed the rights characters ?
I'dont' modify the lines of text, it's just a problem of conversion between unicode and utf-8 here's my code:
FileReader fileReader = new FileReader("tweets.json"); BufferedReader bufferedReader = new BufferedReader(fileReader); File tmp = new File("out.txt"); FileWriter fileWriter = new FileWriter(tmp); BufferedWriter bw = new BufferedWriter(fileWriter); ... String line = bufferedReader.readLine(); bw.write(line);