⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treereporter.java

📁 随书的代码
💻 JAVA
字号:
import javax.xml.parsers.*;  // JAXPimport org.w3c.dom.Node;import org.xml.sax.SAXException;import java.io.IOException;public class TreeReporter {  public static void main(String[] args) {         if (args.length <= 0) {      System.out.println("Usage: java TreeReporter URL");      return;     }         TreeReporter iterator = new TreeReporter();    try {      // Use JAXP to find a parser      DocumentBuilderFactory factory        = DocumentBuilderFactory.newInstance();      // Turn on namespace support      factory.setNamespaceAware(true);      DocumentBuilder parser = factory.newDocumentBuilder();            // Read the entire document into memory      Node document = parser.parse(args[0]);             // Process it starting at the root      iterator.followNode(document);    }    catch (SAXException e) {      System.out.println(args[0] + " is not well-formed.");      System.out.println(e.getMessage());    }       catch (IOException e) {       System.out.println(e);     }    catch (ParserConfigurationException e) {       System.out.println("Could not locate a JAXP parser");     }    } // end main  private PropertyPrinter printer = new PropertyPrinter();    // note use of recursion  public void followNode(Node node) throws IOException {        printer.writeNode(node);    if (node.hasChildNodes()) {      Node firstChild = node.getFirstChild();      followNode(firstChild);    }    Node nextNode = node.getNextSibling();    if (nextNode != null) followNode(nextNode);      }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -