bettersaxchecker.java
来自「随书的代码」· Java 代码 · 共 41 行
JAVA
41 行
import org.xml.sax.*;import org.xml.sax.helpers.XMLReaderFactory;import java.io.IOException;public class BetterSAXChecker { public static void main(String[] args) { if (args.length <= 0) { System.out.println("Usage: java BetterSAXChecker URL"); return; } String document = args[0]; try { XMLReader parser = XMLReaderFactory.createXMLReader(); parser.parse(document); System.out.println(document + " is well-formed."); } catch (SAXParseException e) { System.out.print(document + " is not well-formed at "); System.out.print("Line " + e.getLineNumber() + ", column " + e.getColumnNumber() ); System.out.println(" in the entity " + e.getSystemId()); } catch (SAXException e) { System.out.println("Could not check document because " + e.getMessage()); } catch (IOException e) { System.out.println( "Due to an IOException, the parser could not check " + document ); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?