Android开发中常用到方法总结 第5页
return appList;
}
16.将流转成字节数组
public byte[] stream2Bytes(InputStream is) throws IOException {
byte[] mByte;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer, 0, 1024)) != -1) {
baos.write(buffer, 0, length);
}
baos.flush();
mByte = baos.toByteArray();
baos.close();
return mByte;
}