首页
IT
登录
6mi
u
盘
搜
搜 索
IT
App系列------如何把asset目录下文件copy到机台中
App系列------如何把asset目录下文件copy到机台中
xiaoxiao
2026-03-08
8
之前提到如何把文件放到asset目录下,现在就要把文件从asset文件夹中copy到机台里
public boolean
copyApkFromAssets(Context context, String fileName, String path) {
boolean
copyIsFinish =
false
;
// Toast.makeText(installCtools.this,this.getString(R.string.text_error),Toast.LENGTH_LONG).show();
try
{ InputStream is = context.getAssets().open(fileName);
int
count = is.available(); Log.
d
(
"matt-"
,
"count "
+ count); File file =
new
File(path); file.createNewFile(); FileOutputStream fos =
new
FileOutputStream(file);
byte
[] temp =
new byte
[
1024
];
int
i =
0
;
while
((i = is.read(temp)) >
0
) { fos.write(temp,
0
, i); } fos.close(); is.close(); copyIsFinish =
true
; }
catch
(IOException e) { e.printStackTrace(); }
return
copyIsFinish; }
转载请注明原文地址: https://ju.6miu.com/read-1307731.html
最新回复
(
0
)