Why am i getting ?? when i try to read ä character from a text file in java?

后端 未结 2 1510
南旧
南旧 2021-01-29 05:51

I am trying to read text from a text file. There are some special characters like å,ä and ö. When i make a string and print out that string then i get ?? from these special char

2条回答
  •  清歌不尽
    2021-01-29 06:25

    The problem might not be with the file but with the console where you are trying to print. I suggest you follow the following steps

    1. Make sure the file you are reading is encoded in UTF-8.
    2. Make sure the console you are printing to has the proper encoding/charset to display these characters

    Finally, this article Unicode - How to get characters right? is a must read.

提交回复
热议问题