public void seek(long pos)
          throws IOException
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.自己查JDK类库帮助吗,.
     try{
          a.seek(n);
     }catch(IOException e){
     }
你先seek到要改的地方,再write就行了.

解决方案 »

  1.   

    RandomAccessFile类可以实现对文件的随机读写操作。RandomAccessFile类提供两种构造方法:(1)public RandomAccessFile(File file,String mode)throws IOException
    (2)public RandomAccessFiel(String name,String mode)throws FileNotFoundException注:其中第一个参数指出文件的路径,第二个参数指出文件的是否可读写("r"和"rw")。publc void seek(long pos)将文件位置指针移到pos指出的位置上。
      

  2.   

    seek是无返回值的啊,那么查到位置有什么用?还有如何修改TXT文件中的数值啊?比如把5改成4
      

  3.   

    将文件位置指针移到pos指出的位置上有什么用吗?