代码如下
import java.io.*;
public void PUTLINE ( String strFilePath,String strLine ) throws Exception
{
File file=new File(strFilePath);
BufferedWriter bw=new BufferedWriter(new FileWriter(file,true));
try
{
bw.write(strLine);
bw.newLine();
}
catch(IOException e)
{
}
finally
{
bw.flush();
bw.close();
}
}
我这段程序在linux下执行,写出来的文本文件是乱码,请高手赐教!
import java.io.*;
public void PUTLINE ( String strFilePath,String strLine ) throws Exception
{
File file=new File(strFilePath);
BufferedWriter bw=new BufferedWriter(new FileWriter(file,true));
try
{
bw.write(strLine);
bw.newLine();
}
catch(IOException e)
{
}
finally
{
bw.flush();
bw.close();
}
}
我这段程序在linux下执行,写出来的文本文件是乱码,请高手赐教!
你将它改为gbk或gb231String str=new String(strLine.getBytes("UTF-8"),"gbk");