public String copyfile(String source, String destdir) {
String filename = "";
try {
String filepath = source;
File ofile = new File(filepath);
File syspath = new File(destdir);
if (syspath.exists()) {
Del_File(syspath.getAbsolutePath());
syspath.mkdirs();
}
else {
syspath.mkdirs();
}
File[] of = ofile.listFiles();
for (int i = 0; i < of.length; i++) {
File tf = of[i];
if (tf.isDirectory()) {
String dirname = tf.getName();
copyfile(tf.getAbsolutePath(), destdir + "/" + dirname);
}
else {
String name = tf.getName();
FileInputStream fis = new FileInputStream(tf);
FileOutputStream fos = new FileOutputStream(destdir + "/" + name);
byte[] tempch = new byte[fis.available()];
fis.read(tempch);
fos.write(tempch);
fos.flush();
fos.close();
fis.close();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return filename;
}