// 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
}
Friday, June 10, 2011
Java -=- Moving a file
To move a file from a directory to another, simply do the following:
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment