RandomAccessFile openfile = new RandomAccessFile( this.OpenPathFileName,"r" );
            File file = new File( this.SavePathFileName + "temp" );
RandomAccessFile savefile = new RandomAccessFile( file,"rw" );            readline = openfile.readLine();
 savefile.writeBytes( readline  );

解决方案 »

  1.   

    下面的例子从目录中读取后缀为html的文件
    File dir=new File("/");
    Filter filter=new Filter("html");
    System.out.println("list html files in directory   "+dir);
    String files[]=dir.list(filter);
    for(int i=0;i<files.length;i++){
      File f=new File(files[i]);
        if(f.isFile())
          System.out.println("file   "+f);
        else
          System.out.println("sub directory    "+f);
    }你改改就可以用了。你建了文件名数组,然后产生随机数做数组下标,再打开文件,就可以了