String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
        int filesize = input.available();
        byte[] filecontents = new byte[filesize];
        input.read(filecontents, 0, filesize);
        input.close();
        String encoding = env.getEncoding();
        String rawDoc = (encoding!=null)
            ? new String(filecontents, encoding)
            : new String(filecontents);
        String upper = null;
        int bodyIdx = rawDoc.indexOf("<body");
        if (bodyIdx == -1) {
            bodyIdx = rawDoc.indexOf("<BODY");
            if (bodyIdx == -1) {
                upper = rawDoc.toUpperCase();
                bodyIdx = upper.indexOf("<BODY");
                if (bodyIdx == -1) {
                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
                                       "javadoc.Body_missing_from_html_file");
                    return "";
                }
            }
        }
        bodyIdx = rawDoc.indexOf('>', bodyIdx);
        if (bodyIdx == -1) {
            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
                               "javadoc.Body_missing_from_html_file");
            return "";
        }
        ++bodyIdx;
        int endIdx = rawDoc.indexOf("</body", bodyIdx);
        if (endIdx == -1) {
            endIdx = rawDoc.indexOf("</BODY", bodyIdx);
            if (endIdx == -1) {
                if (upper == null) {
                    upper = rawDoc.toUpperCase();
                }
                endIdx = upper.indexOf("</BODY", bodyIdx);
                if (endIdx == -1) {
                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
                                       "javadoc.End_body_missing_from_html_file");
                    return "";
                }
            }
        }
        return rawDoc.substring(bodyIdx, endIdx);
    }