更正一下:raf = new RandomAccessFile("status.txt", "rw");

解决方案 »

  1.   

    public final void writeInt(int v)
                        throws IOException
    Writes an int to the file as four bytes, high byte first. The write starts at the current position of the file pointer.
    注意这里写进去的int是四个字节的
      

  2.   

    更正一下:raf = new RandomAccessFile("status.txt", "rw");
    or更正一下:raf = new RandomAccessFile("status.txt", "r");
    有四种类型
    "r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown.  
    "rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.  
    "rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.  
    "rwd"   Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.