标题:关于用randomAccessFIle类中使用readUTF()和writeUTF()出现乱码的现象
只看楼主
枫xby
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:82
专家分:371
注 册:2014-10-19
结帖率:71.43%
 问题点数:0 回复次数:0 
关于用randomAccessFIle类中使用readUTF()和writeUTF()出现乱码的现象
try{
             RandomAccessFile out = new RandomAccessFile(f,"rw");
             out.seek(out.length());      //定位到文件的末尾
             out.writeUTF(s);
             out.close();
             return "内容已成功写入到文件";
             }
         catch(IOException e){
             return "不能写入文件";
         }

 try{
                   RandomAccessFile file = new RandomAccessFile(f,"r");    //只读
                   String temp = null;                                           //*
                   while((temp = file.readUTF()) != null){                  //readUTF()从文件读取一个utf字符
                       byte d[] = temp.getBytes("ISO-8859-1");
                       temp = new String(d);
                       out.print("<br>"+temp);
                       }
                       file.close();
搜索更多相关主题的帖子: return return null null file file 
2015-11-14 20:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-459205-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014678 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved