File 类有方法,可以移动。

解决方案 »

  1.   

    用File.renameTo(File dest)方法就可以移动了,同时还可以改名。import java.io.*;
    public class FileMove
    {
    public static void main(String[] args)
    {
    File fsource=new File("c:\\q.txt");
    File fdest=new File("d:\\a.txt");
    fsource.renameTo(fdest);
    //把c:\q.txt移动到d:\下,且改名为a.txt
    }    
    }
      

  2.   

    renameTo其实还是从一个地方用流读出来,在用流写到另一个地方
    用renameTo好像能否成功好像还取决于系统平台
    Whether or not this method can move a file from one filesystem to another is platform-dependent