private void CopyAssets(String assetDir, String dir) {
String[] files;
try {
// 获得Assets一共有几多文件
files = this.getResources().getAssets().list(assetDir);
} catch (IOException e1) {
return;
}
File mWorkingPath = new File(dir);
// 如果文件路径不存在
if (!mWorkingPath.exists()) {
// 创建文件夹
if (!mWorkingPath.mkdirs()) {
// 文件夹创建不成功时调用
}
}
for (int i = 0; i < files.length; i++) {
try {
// 获得每个文件的名字
String fileName = files[i];
// 根据路径判断是文件夹还是文件
if (!fileName.contains(".")) {
if (0 == assetDir.length()) {
CopyAssets(fileName, dir + fileName + "/");
} else {
CopyAssets(assetDir + "/" + fileName, dir + "/"
+ fileName + "/");
}
continue;
}
File outFile = new File(mWorkingPath, fileName);
if (outFile.exists())
outFile.delete();
InputStream in = null;
if (0 != assetDir.length())
in = getAssets().open(assetDir + "/" + fileName);
else
in = getAssets().open(fileName);
OutputStream out = new FileOutputStream(outFile);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有