String content = null;
RandomAccessFile file = null;
try{
content = new String(protocolDataQueueElement.mData,2,length,"gb2312");
if(!mFile.exists()){
mFile.createNewFile();
}
file = new RandomAccessFile(mFile,"rw");
file.seek(file.length());
file.write(content.getBytes("gb2312"));
file.write("\n".getBytes());
}catch(Exception e){
e.printStackTrace();
}finally{
if(file != null){
try {
file.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
解决RandomAccessFile 写文件汉字乱码问题
最新推荐文章于 2023-07-25 17:25:24 发布