Android Utililty Methods Directory Copy

List of utility methods to do Directory Copy


The list of methods to do Directory Copy are organized into topic(s).


voidCopyDir(String sourcedir, String destdir)
This class copies an input files of a directory to another directory not include subdir
File dest = new File(destdir);
File source = new File(sourcedir);
String[] files = source.list();
try {
} catch (Exception ex) {
    throw new Exception("CopyDir:" + ex.getMessage());
for (int i = 0; i < files.length; i++) {
    String sourcefile = source + File.separator + files[i];
    String destfile = dest + File.separator + files[i];
    File temp = new File(sourcefile);
    if (temp.isFile()) {
        try {
            copy(sourcefile, destfile);
        } catch (Exception ex) {
            throw new Exception("CopyDir:" + ex.getMessage());
booleancopyDir(File source, File destination)
copy Dir
InputStream in = null;
OutputStream out = null;
label222: try {
    if (source.isDirectory()) {
        if (!destination.exists()) {
        String[] children = source.list();
voidcopyDirectory(@NotNull String srcDir, @NotNull String dstDir, @NotNull final List excludes)
copy Directory
logger.entry(srcDir, dstDir, excludes);
final File source = new File(srcDir);
if (!source.exists()) {
    throw logger.throwing(new FileNotFoundException(srcDir));
final File destination = new File(dstDir);
booleancopyDirectory(File from, File to)
Copy a directory and all of its contents.
return copyDirectory(from, to, (byte[]) null);
booleancopyDirectory(File from, File to, byte[] buffer)
copy Directory
if (from == null)
    return false;
if (!from.exists())
    return true;
if (!from.isDirectory())
    return false;
if (to.exists())
    return false;
voidcopyDirectory(File source, File destination)
copy Directory
if (source.exists() && source.isDirectory()) {
    if (!destination.exists()) {
    File[] fileArray = source.listFiles();
    for (int i = 0; i < fileArray.length; i++) {
        if (fileArray[i].isDirectory()) {
booleancopyDirectory(String from, String to)
copy Directory
return copyDirectory(new File(from), new File(to));
voidcopyDirectory(String sourceDirName, String destinationDirName)
copy Directory
copyDirectory(new File(sourceDirName), new File(destinationDirName));
voidcopyDirectory(File sourceDir, File targetDir)
copy Directory
if (null != sourceDir) {
    File[] file = sourceDir.listFiles();
    for (int i = 0; i < file.length; i++) {
        if (file[i].isFile()) {
            File sourceFile = file[i];
            File targetFile = new File(targetDir.getAbsolutePath()
                    + File.separator + file[i].getName());