import java.io.*;
class test
{
public static void main(String[] args){
String content = "corr_name=\"福莱特公司\" cust";
System.out.println(content);
FileWriter fw = null;
try
{
fw = new FileWriter("D:/test.xml"); //建立FileWriter对象,并实例化fw
byte dbbyte1[] = content.getBytes("UTF-8");
String content1 = null;
content1 = new String(dbbyte1,"UTF-8");
System.out.print(content1.getBytes().length); //向控制台输出内容
fw.write(content1); //向一个文本txt文件输出内容
fw.close();
}
catch (IOException ex) {
}
}}
改了一行,String构造时要选编码方式
class test
{
public static void main(String[] args){
String content = "corr_name=\"福莱特公司\" cust";
System.out.println(content);
FileWriter fw = null;
try
{
fw = new FileWriter("D:/test.xml"); //建立FileWriter对象,并实例化fw
byte dbbyte1[] = content.getBytes("UTF-8");
String content1 = null;
content1 = new String(dbbyte1,"UTF-8");
System.out.print(content1.getBytes().length); //向控制台输出内容
fw.write(content1); //向一个文本txt文件输出内容
fw.close();
}
catch (IOException ex) {
}
}}
改了一行,String构造时要选编码方式
解决方案 »
- 急!!!!!!!!RPCServiceClient-调用webservice客户端。。。。
- MyEclipse6.0.1+Tomcat发布时出现问题:严重: Error initializing endpoint java.lang.Exceptio
- Quartz 同一时间点,两个以上任务,有时其中某一任务不执行.
- java.lang.OutOfMemoryError~~~~
- float类型精度问题
- Struts1.1+Spring2.0+HIbernate3.0整合问题
- 为什么在eclipse中配置struts标签总是出错
- 机器上有tomcat6和7,我启动6出来的却是7的画面
- springMVC 使用json出错java.sql.SQLException: Positioned Update not supported.
- 大佬们 有人看得懂这段100行左右的代码吗??能不能解释一下!!
- 一个SQL2000 DB连接的问题~~
- 请教struts的actionmapping中input属性转向的问题
String content1 = null;
content1 = new String(dbbyte1);
System.out.print(content1.getBytes().length);
上面的删掉,不要转码就OK了