code: private static byte[] readAllBytes(InputStream is) throws IOException {
          byte[] buffer = new byte[8192];
          ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
          int n;
          while ((n = is.read(buffer)) != -1) {
              baos.write(buffer, 0, n);
          }
          return baos.toByteArray();
      }
docs: /*
  Reads the entire contents of an InputStream into a byte array.
  
  @param is the InputStream to read from
  @return the bytes read from the InputStream