code: private static final int readBase64(InputStream in, boolean throwExceptions) throws IOException {
      int read;
      int numPadding = 0;
      do {
        read = in.read();
        if (read == END_OF_INPUT) {
          return END_OF_INPUT;
        }
        read = reverseBase64Chars[(byte) read];
        if (throwExceptions && (read == NON_BASE_64 || (numPadding > 0 && read > NON_BASE_64))) {
          throw new Base64DecodingException(
              MessageFormat.format(
                  "Unexpected char",
                  (Object[]) new String[]{
                      "'" + (char) read + "' (0x" + Integer.toHexString(read) + ")"
                  }
              ),
              (char) read
          );
        }
        if (read == NON_BASE_64_PADDING) {
          numPadding++;
        }
      } while (read <= NON_BASE_64);
      return read;
    }
docs: Reads the next (decoded) Base64 character from the input stream. Non Base64 characters are
  skipped.
  
  @param in Stream from which bytes are read.
  @param throwExceptions Throw an exception if an unexpected character is encountered.
  @return the next Base64 character from the stream or -1 if there are no more Base64 characters
  on the stream.
  @throws IOException if an IO Error occurs.
  @throws Base64DecodingException if unexpected data is encountered when throwExceptions is
  specified.
  @since ostermillerutils 1.00.00