浪迹天涯
web报表设计器....
posts - 61,comments - 71,trackbacks - 0
try   {                       RandomAccessFile out = new  RandomAccessFile(file, " rw " );             
out.seek(out.length());
// 将指针移动到文件末尾
out.writeBytes( " \r\n " );
mess 
=   " 写入文件 " ;
byte  buffer[]  =   new   byte [ 1024 ];
buffer 
=  mess.getBytes();
out.write(buffer); 
out.close();
// 关闭文件流 
}
  catch  (IOException e)  {
  e.printStackTrace();
}
posted on 2008-03-26 14:19 JJCEA 阅读(5199) 评论(4)  编辑  收藏 所属分类: java文件操作

FeedBack:
# re: 解决RandomAccessFile写入文件乱码的办法
2008-03-26 14:54 | Find it, try it, experience it
I didn't see any thing here can resolve the problem related to encoding.  回复  更多评论
  
# re: 解决RandomAccessFile写入文件乱码的办法[未登录]
2008-03-26 15:07 | AA
明明就是追加,谁都会的  回复  更多评论
  
# re: 解决RandomAccessFile写入文件乱码的办法
2008-03-28 11:07 | senlin-blog
你会说明你能,但不一定谁都会的,我是说明解决乱码的问题  回复  更多评论
  
# re: 解决RandomAccessFile写入文件乱码的办法
2008-03-28 13:18 | Find it, try it, experience it
But...actually there is nothing related to encoding/decoding, you can have a try to set your JVM default encoding to be iso8859-1 or something other than GB2312/GBK/ GB18030, probly you will get something like "XXX" with your code with your input message "写入文件".  回复  更多评论