code: public static byte[] encode(InputStream in) {
          Base64OutputStream out = null;
          try {
              ByteArrayOutputStream bytes = new ByteArrayOutputStream();
              out = new Base64OutputStream(bytes);
              byte[] buf = new byte[4096];
              int len;
              while ((len = in.read(buf)) > 0) {
                  out.write(buf, 0, len);
              }
              out.flush();
              return bytes.toByteArray();
          } catch (IOException e) {
              return null;
          } finally {
              try {
                  in.close();
                  if (out != null) out.close();
              } catch (IOException e) {
                  throw new FaultException(e);
              }
          }
      }
docs: Encodes an input stream to base64, returning bytes.
  <p>
  The stream is guaranteed to be closed when this method returns, whether
  successful or not.
  
  @param in stream to encode
  @return encoded bytes, or null if there's an error reading the stream