?? client.java
字號:
package com.briup.main;
import java.lang.reflect.Method;
import java.util.*;
import com.briup.*;
import com.briup.exception.*;
public class Client {
Config config;
Log log;
Backup backup;
Gather gather;
NetClient netClient;
public Client(){
init();
try {
this.backup=config.getBackup();
this.gather=config.getGather();
this.log=config.getLog();
this.netClient=config.getNetClient();
} catch (ConfigException e) {
e.printStackTrace();
}
}
@SuppressWarnings({ "unused", "unchecked" })
private void init() {
Properties props=new Properties();
props.setProperty("class_name", "com.briup.impl.config.ConfigImpl");
props.setProperty("constructor_method", "newInstance");
props.setProperty("args", "java.util.Properties");
props.setProperty("config_file_path", "src/com/briup/resource/config.xml");
String class_name=props.getProperty("class_name");
String constructor_method=props.getProperty("constructor_method");
String args=props.getProperty("args");
try {
Class c = Class.forName(class_name);
Method method=c.getMethod(constructor_method, Properties.class);
config=(Config)method.invoke(null, new Object[]{props});
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Client client=new Client();
Collection<BIDR> collection=null;
Collection<BIDR> c=null;
try {
try {
collection=client.backup.load();
if(collection.size()!=0){
client.log.writeInfo("Backup File Load Success!");
client.backup.clear();
}
} catch (Exception e) {
e.printStackTrace();
}
c=client.gather.doGather();
collection.addAll(c);
client.log.writeInfo("Gather Information Success!");
} catch (Exception e) {
e.printStackTrace();
}
try {
client.netClient.send(collection);
client.log.writeInfo("File Send Success!");
} catch (Exception e1) {
try {
client.backup.store(collection);
client.log.writeInfo("Backup File Success!");
} catch (Exception e) {
e.printStackTrace();
}
e1.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -