汉字输出到文件

cheny 2003-09-30 09:39:31
String s = "大家好";
DataOutputStream out1 = new DataOutputStream(
new BufferedOutputStream(new FileOutputStream("data.log",true)));
out1.writeBytes(s);

怎么输出屏幕是对,输出到文件,中文就是乱码了
请问怎么解决
...全文
16 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzgcxy 2003-09-30
  • 打赏
  • 举报
回复
UP!
hell99081015 2003-09-30
  • 打赏
  • 举报
回复
系统不是默认的英文嘛,那看看gb2312
怎么样?
aResponse.setContentType( "text/html;charset=GB2312" );
PrintWriter aOut = aResponse.getWriter();
aOut.println(s);
cheny 2003-09-30
  • 打赏
  • 举报
回复
谢谢,可以了
Yanbin_Q 2003-09-30
  • 打赏
  • 举报
回复
对的,用Writer,因为Writer支持Unicode,写中文也不应有乱码。
PrintWriter out
= new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
OneNight 2003-09-30
  • 打赏
  • 举报
回复
用不要用DataOutputStream,用PrintWriter试试~
PrintWriter out = new PrintWriter(new FileOutputStream("data.log", true));
out.println(s);

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧