Unicode File IO in Codename One

六月ゝ 毕业季﹏ 提交于 2019-12-06 15:08:29

The readToString() method reads with UTF-8 encoding. If you encoded the file in one of the ASCII/ANSI encoding you need to either fix it for UTF-8 or specify the specific encoding to that method.

readUTF from DataInputStream is something completely different designed for encoded streams and not for text files. DataInputStream in general is not designed for text files in Java, you should be using Reader/InputStreamReader for that sort of stuff.

getBytes() uses the platform specific encoding which is rarely what you want you should use getBytes(String).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!