在一个盘上,如何将一个目录及目录下的所有子目录和文件移动到另一个目录下。
希望不通过文件复制方法,有没有好的方法,请高手赐教

解决方案 »

  1.   

    哈哈,不用复制的方法,楼主牛啊,知道WINDOWS怎么实现移动文件的吗?
    我也想不复制就能移动文件,听楼主高见了占个座位先
      

  2.   

    Windows也是先赋值,再删除的方法
      

  3.   

    public static boolean copy(String input, String output) throws Exception {
            int BUFSIZE = 65536;
            FileInputStream fis = new FileInputStream(input);
            FileOutputStream fos = new FileOutputStream(output);
            try {
                int s;
                byte[] buf = new byte[BUFSIZE];
                while ((s = fis.read(buf)) > -1 ){
                    fos.write(buf, 0, s);
                }
           }
           catch (Exception ex) {
               throw new Exception("Can not copy " + input + " to " + output + ex.getMessage());
           }
           finally {
               fis.close();
               fos.close();
           }
            return true;
        }把它改改。弟归一下目录,一个一个复制过去.
      

  4.   

    呵呵 找到方法了 用java.io.File.renameTo() 这个是和dos下的move命令相同的功能