2020-04-23
/**
* 复制Assets下的文件到存储卡
*
* @param assetsFileName assets下的要复制的文件名
* @param sdFolder sd卡保存位置的文件夹路径
* @return sd卡保存的文件路径
*/
public String copyVideoToLocalPath(String assetsFileName, String sdFolder) {
String localFilePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + sdFolder + "/" + assetsFileName;
if (new File(localFilePath).exists()) return localFilePath;
try {
InputStream myInput = this.getAssets().open(assetsFileName);
//用的是com.blankj.utilcode 库的工具
if (FileIOUtils.writeFileFromIS(localFilePath, myInput)) {
return localFilePath;
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
网友评论