boolean flag = false;
try
{
if (src.isDirectory())
{
if (!dst.exists())
{
dst.mkdir();
}
File[] srcArr = src.listFiles();
ArrayList flist = new ArrayList();
for(int i=0;i
if(!srcArr[i].isDirectory())
{
String fileName = srcArr[i].getAbsolutePath();
String[] fileArr = fileName.split("\\\\");
flist.add(fileArr[fileArr.length-1]);
}
}
for (int i=0; i
copyAllFiles(new File(src, flist.get(i).toString()), new File(dst, flist.get(i).toString()));
}
flag = true;
}
else
{
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
in.close();
out.close();
flag = true;
}
}
catch(Exception ex)
{ flag = false; }
return flag;
}
0 comments:
Post a Comment