Java字符串中的西班牙字符出现问题 [英] Issue with spanish characters in java string

查看:157
本文介绍了Java字符串中的西班牙字符出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java字符串中的西班牙字符有问题.我在文件中有内容,当我尝试使用InputStreamReader将其转换为java对象时,某些字符串的输出为cÃmo",应为cómo".这正在像其他西班牙人一样发生

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 is "cómo" which should be "cómo". This is happening other spanish like

á=á é=é í=à ó=ó ú=Ã

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

还有更多..

请帮助我将其转换为适当的输出.

Could you please help me to convert it appropriate output.

预先感谢

推荐答案

您是否尝试过在InputStreamReader的构造函数中指定字符编码,如下所示:

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");

这篇关于Java字符串中的西班牙字符出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆