?? xml2dbtool.java
字號(hào):
/*
* *****************************************************
* Copyright (c) 2005 IIM Lab. All Rights Reserved.
* Created by xuehao at Dec 5, 2005
* Contact: zxuehao@mail.ustc.edu.cn
* *****************************************************
*/
package org.indigo.db;
import java.io.File;
import java.util.Iterator;
import java.util.Vector;
import org.indigo.xml.XmlTableReader;
/**
* 采集輔助工具。
* 讀取指定目錄中的xml文件。
* @author wbz
*
*/
public class Xml2DBTool
{
private Vector itsFiles=null;
private String itsRootPath=null;
public Xml2DBTool()
{
}
public void setRootPath( String path )
{
itsRootPath = path;
getFiles( path );
}
private void getFiles( String fileName )
{
File source = new File( fileName );
String []files = source.list();
for( int i=0; i<files.length; i++ )
{
File file = new File( source.getPath(), files[i] );
if( file.isDirectory() )
{
getFiles( file.toString() );
}else
{
String str = file.getAbsolutePath();
if( itsFiles==null )
{
itsFiles = new Vector();
}
if( str.endsWith(".xml") )
itsFiles.add( str );
// System.out.println( str );
}
}
}
public Iterator getFiles()
{
return itsFiles.iterator();
}
public static void main(String[] args)
{
String name;
Xml2DBTool tool = new Xml2DBTool();
name = "D:/IExtract/data/農(nóng)業(yè)網(wǎng)站/安徽省";
tool.setRootPath( name );
Iterator it = tool.getFiles();
while( it.hasNext() )
{
name = (String) it.next();
// System.out.println( name );
System.out.println( "created the xml file "+ name );
XmlTableReader reader = new XmlTableReader( name );
reader.readAll();
System.out.println( name + " been have inserted the data into db." );
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -