输入流本地存储
外置存储卡存储
一般情况下小文件图片之类的不建议存在外置存储存在SharedPreference当中较好
VacationService vacationService= HttpRPC.getService(VacationService.class, AppUtil.getYzamsAddr());
InputStream result= vacationService.downloadSickCertificate(certificatePicID);
if (result == null) {
throw new RuntimeException("stream is null");
} else {
try {
File file= new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg");
if(!file.exists()){
file.createNewFile();}
LogUtil.e(".............0.0.0.."+Environment.getExternalStorageDirectory());
AppUtil.setPicTimeMillersName(file.getName());
LogUtil.e("................."+file.getName());
FileOutputStream fileOutputStream=new FileOutputStream(file);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[10240];
int len = 0;
while ((len = result.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
fileOutputStream.write(buffer);
}
byte[] data=outStream.toByteArray();
if (data != null) {
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
}
outStream.close();
result.close();
} catch (Exception e) {
e