xmlconfigparser.java
来自「一个完整的网上书店」· Java 代码 · 共 41 行
JAVA
41 行
package com.ascenttech.ebookstore.util;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import java.util.Properties;
public class XMLConfigParser extends DefaultHandler
{
private Properties props;
private StringBuffer currentValue =new StringBuffer();
public XMLConfigParser()
{
this.props=new Properties();
}
public Properties getProps()
{
return this.props;
}
public void startElement(String uri,String localName,String qName,Attributes attributes)throws SAXException
{
currentValue.delete(0,currentValue.length());
}
public void characters(char[] ch, int start, int length) throws SAXException {
currentValue.append(ch, start, length);
}
public void endElement(String uri,String localName,String qName)throws SAXException
{
props.put(qName.toLowerCase(),currentValue.toString().trim());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?