ruby,java实现移动文件夹代码,rubyjava,Ruby 实现移动文件夹
分享于 点击 37100 次 点评:278
ruby,java实现移动文件夹代码,rubyjava,Ruby 实现移动文件夹
Ruby 实现移动文件夹
从源文件夹移动所有子文件以及文件夹到目标文件夹,如果已存在则复制。
require 'fileutils'FileUtils.mv src, dest
Java
// This will not move files across drives. // File (or directory) to be moved File file = new File("filename"); // Destination directory File dir = new File("directoryname"); // Move file to new directory boolean success = file.renameTo(new File(dir, file.getName())); if (!success) { // File was not successfully moved }
参考: The Java Developers Almanac 1.4
用户点评