RandomAccessFile对文件的内部结构要求很严整,你的文件符合吗?

解决方案 »

  1.   

    不好意思
    我不大明白
    是指文件格式吗
    是.ini文件的
      

  2.   

    不知道怎么用中文说了:(比如说,用RandomAccessFile, 你要读取文件内部一段数据,那么就必须知道内部的数据排列格式(不知道说得准不准确)。如果不知道,就很麻烦。
    看一下下边这个介绍也许会了解多一点。Instances of this class support both reading and writing to a random access file. A random access file behaves like a large array of bytes stored in the file system. There is a kind of cursor, or index into the implied array, called the file pointer; input operations read bytes starting at the file pointer and advance the file pointer past the bytes read. If the random access file is created in read/write mode, then output operations are also available; output operations write bytes starting at the file pointer and advance the file pointer past the bytes written. Output operations that write past the current end of the implied array cause the array to be extended. The file pointer can be read by the getFilePointer method and set by the seek method. It is generally true of all the reading routines in this class that if end-of-file is reached before the desired number of bytes has been read, an EOFException (which is a kind of IOException) is thrown. If any byte cannot be read for any reason other than end-of-file, an IOException other than EOFException is thrown. In particular, an IOException may be thrown if the stream has been closed. 
      

  3.   

    最好用属性文件:import java.util.*;
    import java.io.*;public class TestTest{
    public static void main(String[] args) throws Exception{
    FileInputStream in=new FileInputStream("my.properties");
    Properties p=new Properties();
    p.load(in);
    System.out.println(p.getProperty("UserCount"));
    FileOutputStream out=new FileOutputStream("my.properties");
    p.setProperty("UserCount","3");
    p.load(in);
    System.out.println(p.getProperty("UserCount"));
    }
    }
    my.properties文件放在类文件同一个目录下,格式
    password=12345
    name=hello
    UserCount=2
      

  4.   

    vcmfc,great123,冰棍他妈的老B真难操
    vcmfc,great123,再操冰棍他妈的B----大贱B
    vcmfc,great123,冰棍,你妈是我干的!真的!
    vcmfc,great123,冰棍,Mda在床上等我,怎么办?
    vcmfc,great123,冰棍,Mda叫我晚上去操她!
    vcmfc,great123,冰棍,你老妈前几天跟一条狗搞在一起呀!!
    vcmfc,great123,冰棍,你老妈前几天被狗操翻了
      

  5.   

    你这种针对某个属性的修改
    最好用属性文件(properties)!