utf-8 to ms932 转换(java)

ButfulFigher 2011-03-02 10:25:00
如题
...全文
336 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wang12 2011-03-03
String abc = "你好" //UTF-8
String df = new String(abc.getBytes("utf-8"), "ms932");
回复
magong 2011-03-03
从文件到文件:

try {
InputStream in = new FileInputStream("utf8.txt");
InputStreamReader iReader = new InputStreamReader(in, "UTF-8");
BufferedReader reader = new BufferedReader(iReader);

OutputStream os = new FileOutputStream("ms932.txt");
PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "MS932"));

String aLine;
while ((aLine=reader.readLine())!=null)
writer.println(aLine);
writer.close();
reader.close();
} catch (Exception e) {
e.printStackTrace();
}

回复
ButfulFigher 2011-03-02
补充一点:求代码
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2011-03-02 10:25
社区公告
暂无公告