Reading unicode character in java

后端 未结 7 869
滥情空心
滥情空心 2020-12-05 22:42

I\'m a bit new to java, When I assign a unicode string to

  String str = \"\\u0142o\\u017Cy\\u0142\";
  System.out.println(str);

  final StringBuilder stri         


        
7条回答
  •  被撕碎了的回忆
    2020-12-05 23:12

    You have used FileInputStream and is a byte code reader not character reader. Try using FileReader instead

    something like:

    BufferedReader inputStream = new BufferedReader(new FileReader("C:/a.txt"));

    then you can use the line oriented I/O BufferedReader to read each line. FileInputREader is a low level I/O that you should avoid. You're writing the characters to your file not the bytes, the best approach is to use character streams. for wrinting and reading unless you need to write bytes/binary data.

提交回复
热议问题