java--数据采集系统
java--数据采集系统
分类: Android开发 java讨论区 2011-09-04 17:18 173人阅读 评论(0) 收藏 举报
Gather采集类:
package com.briup.woss.client.impl;
import java.io.*;import java.sql.Timestamp;import java.util.*;import com.briup.pojos.BIDR;import com.briup.woss.client.Gather;public class GatherImpl implements Gather {private static Map map=new HashMap();/*?* 读取up.dat文件,up.dat文件存放的是用户没下线的信息,?* 规定格式为:loginIp,userinfo;*/private static FileReader fr;private static BufferedReader br;static{try{fr=new FileReader("data/up.dat");br=new BufferedReader(fr);String str;while((str=br.readLine())!=null){String subStr[]=str.split(";");for(int i=0;i gather() throws Exception {Collection c=new ArrayList();FileReader fr=new FileReader("data/radwtmp");BufferedReader br=new BufferedReader(fr);int point=readPointFile();int p=point;String str=null;int temp=1;/*?* 读取point文件来确定从哪一条记录开始读?*/while((str=br.readLine())!=null){if(temp<=p){temp++;continue;}point++;String str1 []=str.split("[|]+");if(str1[2].equals("7")){map.put(str1[4], str);}else if(str1[2].equals("8")){String sub=(String)map.get(str1[4]);if(sub!=null){String info[]=sub.split("[|]+");String login_name=info[0].replace("#", "");//去除用户名前面的"#"BIDR bidr=new BIDR();//得到登陆用户名bidr.setAAA_login_name(login_name);//得到登陆IPbidr.setLogin_ip(info[4]);//得到NAS的IPbidr.setNAS_ip(info[1]);/** 创建Timestamp类型的ts1(上线),ts2(下线)*/ Timestamp ts1=new Timestamp(Long.parseLong(info[3]+"000"));Timestamp ts2=new Timestamp(Long.parseLong(str1[3]+"000"));//得到上线时间bidr.setLogin_date(ts1);//得到下线时间bidr.setLogout_date(ts2);//得到上网时间, 以分钟计算int secondTime=Integer.parseInt(str1[3])-Integer.parseInt(info[3]);int minuTime=secondTime/60+1;if(secondTime%60==0)minuTi