Here you can find the source of getBytesFromStream(InputStream inputStream)
public static byte[] getBytesFromStream(InputStream inputStream) throws IOException
//package com.java2s; /**// ww w . ja va 2 s . c o m * License: https://github.com/votingsystem/votingsystem/wiki/Licencia */ import java.io.*; public class Main { private static final int BUFFER_SIZE = 4096; public static byte[] getBytesFromStream(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] buf = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } outputStream.close(); inputStream.close(); return outputStream.toByteArray(); } }