Skip to content

Commit c78a3c1

Browse files
committed
恢复copyAssetFileToSDcard方法
1 parent ec71e2f commit c78a3c1

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

  • android/app/src/main/java/com/supermap/file

‎android/app/src/main/java/com/supermap/file/Utils.java‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88
import java.io.InputStream;
99

1010
public class Utils {
11-
public static void copyAssetFileToSDcard(Context context, String originPath, String targetPath) {
11+
public static void copyAssetFileToSDcard(Context context, String filePath, String fileName) {
1212
InputStream inputStream;
1313
try {
14-
inputStream = context.getResources().getAssets().open(originPath);// assets文件夹下的文件
15-
File file;
16-
if (targetPath.lastIndexOf("/") > 0) {
17-
file = new File(targetPath.substring(0, targetPath.lastIndexOf("/")));
18-
} else {
19-
file = new File(targetPath);
20-
}
14+
inputStream = context.getResources().getAssets().open(fileName);// assets文件夹下的文件
15+
File file = new File(filePath);
2116
if (!file.exists()) {
2217
file.mkdirs();
2318
}
24-
FileOutputStream fileOutputStream = new FileOutputStream(targetPath);// 保存到本地的文件夹下的文件
19+
FileOutputStream fileOutputStream = new FileOutputStream(filePath + "/" + fileName);// 保存到本地的文件夹下的文件
2520
byte[] buffer = new byte[1024];
2621
int count = 0;
2722
while ((count = inputStream.read(buffer)) > 0) {

0 commit comments

Comments
 (0)