您的位置:首页 > 其它

windows创建文本文件默认为ANSI编码,读取文件乱码解决~!

2011-03-01 16:39 651 查看
BufferedReader in = null;
FileInputStream fs = null;
try {
fs = new FileInputStream(new File("C://Users//UserName//workspace//Client//DownloadFileList//1//New Text Document.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
List<String> contents=new ArrayList<String>();
try {
in = new BufferedReader(new InputStreamReader(fs,"GBK"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String line;
try {
while((line = in.readLine())!=null) {
contents.add(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐