class XmlReader extends Reader {

    static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
        String encoding = null;
        if (guessedEnc != null) {
            final byte[] bytes = new byte[BUFFER_SIZE];
            is.mark(BUFFER_SIZE);
            int offset = 0;
            int max = BUFFER_SIZE;
            int c = is.read(bytes, offset, max);
            int firstGT = -1;
            while (c != -1 && firstGT == -1 && offset < BUFFER_SIZE) {
                offset += c;
                max -= c;
                c = is.read(bytes, offset, max);
                firstGT = new String(bytes, 0, offset, guessedEnc).indexOf(">");
            }
            if (firstGT == -1) {
                if (c == -1) {
                    throw new IOException("Unexpected end of XML stream");
                } else {
                    throw new IOException("XML prolog or ROOT element not found on first " + offset + " bytes");
                }
            }
            final int bytesRead = offset;
            if (bytesRead > 0) {
                is.reset();
                String prolog = new String(bytes, guessedEnc).substring(0, firstGT);
                final Matcher m = ENCODING_PATTERN.matcher(prolog);
                if (m.find()) {
                    encoding = m.group(1).toUpperCase(Locale.ENGLISH);
                    encoding = encoding.substring(1, encoding.length() - 1);
                }
            }
        }
        return encoding;
    }

    public  XmlReader(final File file);
    public  XmlReader(final InputStream is);
    public  XmlReader(final InputStream is, final boolean lenient, final String defaultEncoding);
    public  XmlReader(final InputStream is, final boolean lenient);
    public  XmlReader(final URL url);
    public  XmlReader(final URL url, final Map<String, String> requestHeaders);
    public  XmlReader(final URLConnection conn);
    public  XmlReader(final URLConnection conn, final Map<String, String> requestHeaders);
    public  XmlReader(final InputStream is, final String httpContentType);
    public  XmlReader(final InputStream is, final String httpContentType, final boolean lenient, final String defaultEncoding);
    public  XmlReader(final InputStream is, final String httpContentType, final boolean lenient);

}