extractordriver.java
来自「《JAVA与模式》附书中源代码」· Java 代码 · 共 41 行
JAVA
41 行
package com.javapatterns.observer.xmlparser;
import org.xml.sax.*;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.*;
public class ExtractorDriver
{
public static void main(String[] args)
{
if (args.length <= 0)
{
System.out.println("Usage: java ExtractorDriver url");
return;
}
try
{
XMLReader parser = XMLReaderFactory.createXMLReader();
// Since this just writes onto the console, it's best
// to use the system default encoding, which is what
// we get by not specifying an explicit encoding here.
Writer out = new OutputStreamWriter(System.out);
ContentHandler handler = new TextExtractor(out);
parser.setContentHandler(handler);
// parser.parse("file:////c://myxml.xml");
parser.parse(args[0]);
out.flush();
}
catch (Exception e)
{
System.err.println(e);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?