⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 一个信息采集系统...对刚接触JSP和JAVA的人来说还有用
💻 JAVA
字号:
package com.briup.main;import java.util.Collection;import java.util.Date;import java.util.Properties;import com.briup.exception.BackupException;import com.briup.exception.ConfigException;import com.briup.exception.GatherException;import com.briup.exception.NetClientException;import com.briup.inf.Backup;import com.briup.inf.Config;import com.briup.inf.Gather;import com.briup.inf.Log;import com.briup.inf.NetClient;import com.briup.inf.impl.ConfigImpl;import com.briup.pojo.BIDR;public class Client {	private static Config newInstance() {		Config config = null;		Properties pro = System.getProperties();		pro.setProperty("config_file_path", "src/com/briup/config.xml");		config = ConfigImpl.newInstance(pro);		return config;	}	@SuppressWarnings("unchecked")	public static void main(String[] args) {		Config config = newInstance();		Log log = null;		Gather gather = null;		Backup bu = null;		NetClient nc = null;		Collection<BIDR> bidrs = null;		Collection loadDatas = null;		try {			log = config.getLog();			log.writeInfo("instance log module successfully!");			bu = config.getBackup();			log.writeInfo("instance backup module successfully!");			gather = config.getGather();			log.writeInfo("instance gather module successfully!");			nc = config.getNetClient();			log.writeInfo("instance netClient module successfully!");		} catch (ConfigException e) {			e.printStackTrace();			if (log != null) {				log.writeError("instance module failed!");			}		}		try {			log					.writeInfo("ready to gather data! please wait for a moment...................................");			bidrs = gather.doGather();		} catch (GatherException e) {			e.printStackTrace();			log.writeError("gather data failed!!");		}		log.writeInfo("there are " + bidrs.size() + " \t records to gather");		try {			loadDatas = bu.load();			bu.clear();			if (loadDatas != null) {				log.writeInfo(new Date(System.currentTimeMillis())						+ "there are " + loadDatas.size()						+ " records to gather!");				bidrs.addAll(loadDatas);			}		} catch (BackupException e) {			e.printStackTrace();			log.writeError("load data failed!");		}		log.writeInfo("there are " + bidrs.size()				+ " \t records to gather and load!");		try {			log					.writeInfo(new Date(System.currentTimeMillis())							+ "ready to send records! please wait for a moment...................................");			nc.send(bidrs);			log.writeInfo("there are " + bidrs.size() + "  records to send!");		} catch (NetClientException e) {			e.printStackTrace();			log.writeError("send records failed");			try {				bu.store(bidrs);				log						.writeInfo(new Date(System.currentTimeMillis())								+ "there are " + bidrs.size()								+ " \t records to store!");			} catch (BackupException e1) {				e1.printStackTrace();			}		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -