Here you can find the source of readBytes(InputStream is)
public static byte[] readBytes(InputStream is)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static byte[] readBytes(String fileName) { return readByte(new File(fileName)); }/*from ww w. jav a 2s . com*/ public static byte[] readBytes(InputStream is) { try { int size = is.available(); byte[] buf = new byte[size]; is.read(buf); return buf; } catch (Exception e) { e.printStackTrace(); } return null; } public static byte[] readByte(File f) { FileInputStream fis = null; try { fis = new FileInputStream(f); return readBytes(fis); } catch (Exception e) { e.printStackTrace(); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; } }