将文件或目录移动到另外的目录

    // File (or directory) to be moved
    File file = new File();
    
    // Destination directory
    File dir = new File();
    
    // Move file to new directory
    boolean success = file.renameTo(new File(dir, file.getName()));
    if (!success) {
        // File was not successfully moved
    }

你可能感兴趣的:(将文件或目录移动到另外的目录)