阅读背景:

复制文件/文件夹,删除文件/文件夹

来源:互联网 

复制文件夹:

public static boolean copyFolder(String srcFolderFullPath, String destFolderFullPath) {
        try {
            (new File(destFolderFullPath)).mkdirs(); // 如果文件夹不存在 则建立新文件夹
            File file = new File(srcFolderFullPath);
            String[] files = file.list();
            File temp = null;
            for (int i = 0; i < files.length; i++) {
                if (srcFolderFullPath.endsWith(File.separator)) {
                    temp = new File(srcFolderFullPath + files[i]);
                } else {
                    temp = new File(srcFolderFullPath + File.separator + files[i]);
                }
                if (temp.isFile()) {
                    FileInputStream input = new FileInputStream(temp);
                    copyFile(input, destFolderFullPath + "/" + (temp.getName()).toString());
                }
                if (temp.isDirectory()) {// 如果是子文件夹
                    copyFolder(srcFolderFullPath + "/" + files[i], destFolderFullPath + "/" + files[i]);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }public static boolean copyFolder(String



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: