
import javax.xml.parsers.*
import org.w3c.dom.*
import java.io.*
public class XMLUtil
{
//该方法用于从XML配置文件中提取具体类类名,并返回一个实例对象
public static Object getBean()
{
try
{
//创建文档对象
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance()
DocumentBuilder builder = dFactory.newDocumentBuilder()
Document doc
doc = builder.parse(new File("config.xml"))
//获取包含类名的文本节点
NodeList nl = doc.getElementsByTagName("className")
Node classNode=nl.item(0).getFirstChild()
String cName=classNode.getNodeValue()
//通过类名生成实例对象并将其返回
Class c=Class.forName(cName)
Object obj=c.newInstance()
return obj
}
catch(Exception e)
{
e.printStackTrace()
return null
}
}
}
<?xml version="1.0"?>
<config>
<className>test11.CatAdapter</className>
</config>
然后你吧解析处理的值放到数组或LIST或其他的你能存放的对象中。再写SQL插入到数据库就好了啊。主要数据库事务处理或用批处理
DateInputStream dis=new DateInputStream(new FileInputStream(filepath,true))说说这句代码吧。。。首先DateInputStream 应该是DataInputStream 是一个数据输入流。。不是date。。。
然后是 new FileInputStream(filepath,true),FileInputStream应该是一个文件输入流吧。。你在jdk的api里面有找到一个(String,boolean)这样的构造么?、、
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)