开发者

Issue with spanish characters in java string

开发者 https://www.devze.com 2023-02-08 06:42 出处:网络
I have issue with spanish characters in java string. I have a content in a file and when i try to transform it to java object using InputStreamReader, the output of some string i开发者_StackOverflow中

I have issue with spanish characters in java string. I have a content in a file and when i try to transform it to java object using InputStreamReader, the output of some string i开发者_StackOverflow中文版s "cómo" which should be "cómo". This is happening other spanish like

á = á é = é í = í ó = ó ú = ú

and more..

Could you please help me to convert it appropriate output.

Thanks in advance


Have you tried to specify the character encoding in the constructor of InputStreamReader, like so:

FileInputStream fis = new FileInputStream("file.txt");
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");


Specify charset on your InputStreamReader - http://download.oracle.com/javase/1.5.0/docs/api/java/io/InputStreamReader.html#InputStreamReader(java.io.InputStream, java.lang.String)

0

精彩评论

暂无评论...
验证码 换一张
取 消