欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

ruby,java实现移动文件夹代码,rubyjava,Ruby 实现移动文件夹

来源: javaer 分享于  点击 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

相关栏目:

用户点评