- // 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
- }
- //该片段来自于http://www.codesnippet.cn/detail/091020136309.html
来源: http://www.codesnippet.cn/detail/091020136309.html