Here you can find the source of getDoctypeName(InputStream s)
static String getDoctypeName(InputStream s) throws IOException
//package com.java2s; /*/*from w w w .j av a 2 s . c o m*/ Copyright 2012-2018 Michael Pozhidaev <michael.pozhidaev@gmail.com> This file is part of LUWRAIN. LUWRAIN is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. LUWRAIN is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ import java.util.*; import java.io.*; public class Main { static String getDoctypeName(InputStream s) throws IOException { final org.jsoup.nodes.Document doc = org.jsoup.Jsoup.parse(s, "us-ascii", "", org.jsoup.parser.Parser.xmlParser()); List<org.jsoup.nodes.Node> nods = doc.childNodes(); for (org.jsoup.nodes.Node node : nods) if (node instanceof org.jsoup.nodes.DocumentType) { org.jsoup.nodes.DocumentType documentType = (org.jsoup.nodes.DocumentType) node; final String res = documentType.attr("name"); if (res != null) return res; } for (org.jsoup.nodes.Node node : nods) if (node instanceof org.jsoup.nodes.Element) { org.jsoup.nodes.Element el = (org.jsoup.nodes.Element) node; final String res = el.tagName(); if (res != null) return res; } return ""; } }