?? testclient.java
字號(hào):
package lianxi;
import org.com.gather.*;
import java.util.*;
import java.lang.reflect.*;
public class TestClient{
public static void main(String[] args)throws Exception{
Properties pro = new Properties();
String value = System.getProperty("beanFactory.xml");
// 如果沒(méi)有從命令行獲取參數(shù),則初始值為本機(jī)路徑;
if(value == null){
value = "D:/EXAMPLE/NetCTOSS/springGather/beanFactory.xml";
}
pro.setProperty("beanFactory.xml",value);
String config_Class = System.getProperty("config");
if(config_Class == null){
config_Class = "org.com.gather.SpringConfig";
}
ClassLoader cl = ClassLoader.getSystemClassLoader();
Class c = cl.loadClass(config_Class);
Constructor[] ctr = c.getConstructors();
Config config = (Config)ctr[0].newInstance(new Object[]{pro});
// Config config = new SpringConfig(pro);
Gather gather = config.getGather();
long start = System.currentTimeMillis();
Collection col = gather.getData();
BackUp back = config.getBackUp();
Client client = config.getClient();
if(!col.isEmpty()){
Collection backCol = back.load();
if(!backCol.isEmpty()){
//如果成功把備份文件東西調(diào)出,則把備份文件清空;
back.clear();
backCol.addAll(col);
client.send(backCol);
}else{
client.send(col);
back.clear();
}
}else{
Collection backCol = back.load();
System.out.println("采集到的數(shù)據(jù)為空,檢測(cè)備份文件;");
client.send(backCol);
back.clear();
}
long end = System.currentTimeMillis();
long time = end - start;
System.out.println("時(shí)間是:"+time/1000+"秒");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -