Eclipse和WebSphere Studio新的项目交换功能
2009-12-20 00:00:00 来源:WEB开发网最后,添加utility类,它需要类路径变量以进行编译:
在 AuctionUtils 项目中创建名为 test 的包。
在测试包中创建类 DOMClient 。
将以下的内容添加到 DOMClient 类中:
package test;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* @author schacher
*
* This class introduces a hard requirement on DOM APIs.
* Code is for illustrative purposes only.
*/
public class DOMClient {
public static DocumentBuilder getDefaultDocumentBuilder() throws
ParserConfigurationException {
javax.xml.parsers.DocumentBuilderFactory dbf =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
return dbf.newDocumentBuilder();
}
public static Document parseDocument(InputSource inputSource)
throws ParserConfigurationException, IOException, SAXException
{
ClassLoader prevClassLoader =
Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(
DOMClient.class.getClassLoader());
javax.xml.parsers.DocumentBuilder db = getDefaultDocumentBuilder();
return db.parse(inputSource);
} finally {
Thread.currentThread().setContextClassLoader(prevClassLoader);
}
}
}
- ››Eclipse 3.7反编译插件的安装
- ››eclipse CDT NDK环境搭建步骤
- ››Eclipse 如何自定义java class注释
- ››eclipse.ini内存设置
- ››Eclipse+PyDev离线配置Python开发环境
- ››Eclipse下jQuery文件报错解决方案
- ››Eclipse快捷键与使用技巧
- ››Eclipse 常用快捷键 常用技巧My Eclipse常用快捷键...
- ››Eclipse快捷键二
- ››Eclipse快捷键一
- ››WebSphere Application Server 7.0 XML Feature P...
- ››Eclipse+SVN+Google Code配置过程
更多精彩
赞助商链接