快来帮帮忙!!!!!解决绝对给高分 把PrintWriter myFile = new PrintWriter(myFilePath,encoding);这一行改为PrintWriter myFile=new PrintWriter(new FileWriter(myFilePath));应该可以的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你看看jdk1.5的api不就得了。我没用过1.5版本,不过不是有一个PrintWriter(Writer out) 吗?都是以流方式操作的,你在输出时对输出流设置输出的编码方式不就得了,也就是说,对Writer进行编码处理就可以了。 PrintWriter myFile = new PrintWriter(myFilePath,encoding); String strContent = fileContent; myFile.println(strContent); myFile.close();----------PrintWriter myFile = new PrintWriter(myFilePath); String strContent = fileContent; myFile.println(new String(strContent.getBytes(encoding)));//encoding在这里处理 myFile.close(); 我这样改了一下,大部分汉字可以,但是有些汉字还是乱码,啥原因呀,编码是UTF-8 PrintWriter myFile=new PrintWriter(new FileWriter(myFilePath)); String strContent = new String(fileContent.getBytes(encoding));myFile.println(strContent);myFile.close(); new String(fileContent.getBytes(encoding),"UTF-8"); new String(fileContent.getBytes(encoding),"UTF-8");这个不对,encoding本身就是UTF-8 那反过来试试new String(fileContent.getBytes("UTF-8"),encoding); java的ArrayList如何分页?? Oracle版本对java应用程序的影响? spring事务管理不起作用 java对象池的操作(与大家分享下) 求助有关用SSH框架做的分销系统源码(在线等待。。。) java在http请求中传递大数据 配置spring security出错,速救啊! 不用ejb行吗?有顶有分 如何可以看到网页上java applet演示的源程序代码 如何转换entity?高分请教! ?在together中要逆向工程怎么弄,就是从源码生成图 Servlet和JavaBean的区别
PrintWriter(Writer out) 吗?
都是以流方式操作的,你在输出时对输出流设置输出的编码方式不就得了,也就是说,对Writer进行编码处理就可以了。
String strContent = fileContent;
myFile.println(strContent);
myFile.close();
----------
PrintWriter myFile = new PrintWriter(myFilePath);
String strContent = fileContent;
myFile.println(new String(strContent.getBytes(encoding)));//encoding在这里处理
myFile.close();
PrintWriter myFile=new PrintWriter(new FileWriter(myFilePath));
String strContent = new String(fileContent.getBytes(encoding));
myFile.println(strContent);
myFile.close();
这个不对,encoding本身就是UTF-8