AsynchttpClient下载文件,以文件流的形式

2021-05-16 19:30

阅读:447

}

File file = new File(directory, "picture" + System.currentTimeMillis() + ".jpg");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
// 压缩格式
Bitmap.CompressFormat format = Bitmap.CompressFormat.JPEG;
// 压缩比例
int quality = 100;

if (file.exists()) {
file.delete();
}
try {
file.createNewFile();
OutputStream stream = new FileOutputStream(file);
bitmap.compress(format, quality, stream);//压缩格式 压缩比例 输出流
stream.close();
Log.e(TAG, "onSuccess: "+"保存成功" );
} catch (IOException e) {
e.printStackTrace();
}


评论


亲,登录后才可以留言!