code: private static byte[] getBytes(InputStream is) throws IOException {
          ByteArrayOutputStream out = new ByteArrayOutputStream();
  
          byte[] buf = new byte[4096];
  
          while (true) {
              int r = is.read(buf);
              if (r == -1) {
                  out.flush();
                  return out.toByteArray();
              }
              out.write(buf, 0, r);
          }
      }
docs: Returns a byte array from InputStream.
  
  @param is InputStream
  @return byte array
  @throws IOException