public static byte[] toByteArray(InputStream input) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        copy(input, output);
        return output.toByteArray();
    }
Get the contents of an <code>InputStream</code> as a <code>byte[]</code>.
<p>
This method buffers the input internally, so there is no need to use a
<code>BufferedInputStream</code>.

@param input the <code>InputStream</code> to read from
@return the requested byte array
@throws NullPointerException if the input is null
@throws IOException          if an I/O error occurs
pay-java-common/src/main/java/com/egzosn/pay/common/util/IOUtils.java