您的位置:首页 > 编程语言 > Java开发

java生成unicode编码格式的txt文件

2016-06-23 16:12 483 查看
//strFilePath:文件名,strText:要是写入的内容

public static boolean writefile(String strFilePath,String strText)

{
FileOutputStream fos = null;
BufferedOutputStream osw = null;
File file =new File(strFilePath);
try
{
fos = new FileOutputStream(file);
osw = new BufferedOutputStream(fos);
byte[] bom={-1, -2};  
osw.write(bom);  
osw.write(strText.getBytes("UTF-16LE"));
osw.flush();
fos.close();
osw.close();
}
catch(Exception e)
{
e.printStackTrace();   
}

return true;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: