赞
踩
- public static byte[] readInputStream(InputStream ins) {
- if (ins == null) {
- return null;
- }
- BufferedInputStream bis = new BufferedInputStream(ins);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- try {
- byte[] buffer = new byte[128];
- int n = -1;
- while ((n = bis.read(buffer)) != -1) {
- bos.write(buffer, 0, n);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- } finally {
- if (bis != null) {
- try {
- bis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return bos.toByteArray();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。