IO Stream Reading

来源:互联网 发布:免费接单大厅 淘宝 编辑:程序博客网 时间:2024/05/17 05:03
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();}

 
原创粉丝点击