您的位置:首页 > 其它

从assets中拷贝from文件到指定目录下

2015-05-19 09:35 351 查看
/**
*
* 从assets中拷贝from文件到to目录下
* **/
public void copyFile(Context context, String sourPath, String toPath) {

OutputStream output = null;
InputStream input = null;
try {

int read = 0;
input = context.getResources().getAssets().open(sourPath);
output = new BufferedOutputStream(new FileOutputStream(toPath));
byte[] buf = new byte[2048];
while ((read = input.read(buf)) != -1) {
output.write(buf, 0, read);
}

} catch (Exception e) {
Write.error(e.getMessage());
} finally {
try {
if(output !=null){
output.close();
}
if(input!=null){
input.close();
}
} catch (IOException e) {
Write.debug(""+e.getMessage());
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息