inputStreamReader(new FileInputStream(file),"UTF-8")出现乱码的问题
2014-08-07 16:53
393 查看
InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
BufferedReader br = new BufferedReader(reader);
String line = br.readLine();
在读取txt文件时,会出现乱码的问题,有时候并不是程序的错误,而是txt文件没有转换成“UTF-8”的格式:
以下步骤,可以使txt转化为UTF-8的标准格式:
打开Txt文件-->保存-->另存为-->最下面有一个编码 选择UTF-8-->保存-->是
BufferedReader br = new BufferedReader(reader);
String line = br.readLine();
在读取txt文件时,会出现乱码的问题,有时候并不是程序的错误,而是txt文件没有转换成“UTF-8”的格式:
以下步骤,可以使txt转化为UTF-8的标准格式:
打开Txt文件-->保存-->另存为-->最下面有一个编码 选择UTF-8-->保存-->是
相关文章推荐
- 关于response.setContentType("text/html; charset=UTF-8");乱码问题
- filename=new String(filename.getBytes("iso8859-1"),"utf-8") 解决乱码
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- new String("".getBytes("gbk"),"utf-8")与URLEncoder和URLDecoder比较
- 码农小汪-JavaEE乱码 response.setCharacterEncoding 入URIEncoding="utf-8" response.setContentType
- 【HTML】明明加了<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />却还是乱码的可能原因
- VC++6.0中常出现的"unexpected end of file while looking for precompiled header directive"的问题?
- java 乱码详解_jsp中pageEncoding、charset=UTF -8"、request.setCharacterEncoding("UTF-8")
- 关于Ueditor存储在mysql"UTF-8"乱码的问题
- input type="file" 选取文件路径时出现fakepath问题IE浏览器解决办法
- VC++6.0中常出现的"unexpected end of file while looking for precompiled header directive"的问题解决方法
- dhl:ajax无法跨域改用getJSON(解决服务器返回json数据中文为乱码的问题$.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; chars)
- webView.loadUrl("file:///android_asset/table3.html")出现中文乱码的问题
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- IE 下js里面new Date("2011-11-11") 出现nan的问题以及解决方法
- include file="*.html" 时出现乱码解决方案
- filename=new String(filename.getBytes("iso8859-1"),"utf-8") 解决乱码
- 在JSP中,使用get提交方式出现乱码时,为什么要使用new String(s.getBytes("iso-8859-1"),"utf-8");?
- 使用WebView.load(data,"text/html", "utf-8")加载显示乱码问题分析
- response.setContentType("text/html;charset=utf-8")后依然乱码的解决方法