关于用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();