双层for循环遍历数据

public static void main(String[] args) throws IOException {
		String fileContent = "";
		 try   
		    {       
		        File f = new File("F:\\data.txt");      
		        if(f.isFile()&&f.exists())  
		        {       
		            InputStreamReader read = new InputStreamReader(new FileInputStream(f),"UTF-8");       
		            BufferedReader reader=new BufferedReader(read);       
		            String line;       
		            while ((line = reader.readLine()) != null)   
		            {        
//		            	System.err.println(line);
		                fileContent += line;       
		            }         
		            read.close();      
		        }     
		    } catch (Exception e)   
		    {         
		        e.printStackTrace();     
		    }     
//		String str1 = "server info:GPS,陈俊昌,0868120124708592,,104.07252,30.77055,0,304,2016-03-07 21:45:17,2016-03-08 09:35:58,0.0,7796.0,电量(100%) ACC点火(11时48分) 原地设防报警(偏离1.3公里),四川省成都市 金牛区 天回镇街道 北星大道一段西 富顺豆花饭庄(杜太路)北169米,1,15201436524 server info:GPS,渝F07,C03936C6,,107.76313,30.64850,0,185,2016-03-08 09:36:00,2016-03-08 09:35:58,3.1,9114.0,ACC点火(1时38分) 停车超时(1时21分) 原地设防报警(偏离1.9公里),重庆市 梁平县 梁平县双桂街道 建设村东163米,1,18764575470 server info:GPS,渝F03,81242C86,,107.75580,30.65025,0,173,2016-03-08 09:35:59,2016-03-08 09:35:58,2.2,9004.0,ACC点火(1时18分) 停车超时(1时0分) 原地设防报警(偏离1.5公里),重庆市 梁平县 梁平县双桂工业园区 迎宾路西南 重庆啤酒股份有限公司九厂(李家院子)北134米,1,18701364406 server info:GPS,川FN0229,000013635290049,18280583373,104.40778,31.13508,0,118,2016-03-08 09:36:01,2016-03-08 09:35:59,0.2,25039.0,主电开 ACC点火(1时36分) 停车超时报警(14时13分),四川省 德阳市 旌阳区 东湖乡 南泉路267号 乐山街东 青苹果幼儿园(乐山街)东南74米,1,13635290049 server info:GPS,川A0BG61,0353419037024069,13551006396,103.73384,25.56327,0,329,2016-03-08 02:30:28,2016-03-08 09:36:00,4.4,132312.0,停车超时报警(53分) 电量(100%) ACC熄火 油电接通,云南省 曲靖市 麒麟区 西城街道 石马龙山东南481米,1,15166286216";
		String[] strs = fileContent.split("server info:");
		String[] str3 = new String[strs.length];
		List<UdpServerVO> udpList = new ArrayList<UdpServerVO>();
		for (int i = 1; i < strs.length; i++) {
			str3 = strs[i].split(",");
			UdpServerVO udp = new UdpServerVO();
			udp.setId(str3[0]);
			udp.setLicensePlatel(str3[1]);
			udp.setEquipmentId(str3[2]);
			udp.setPhone(str3[3]);
			udp.setLng(str3[4]);
			udp.setLat(str3[5]);
			udp.setSpeed(str3[6]);
			udp.setDirection(str3[7]);
			udp.setGpstime(str3[8]);
			udp.setReceivetime(str3[9]);
			udp.setDayMileage(str3[10]);
			udp.setTotalMileage(str3[11]);
			udp.setState(str3[12]);
			udp.setPosition(str3[13]);
			udp.setValidity(str3[14]);
			udp.setSimCard(str3[15]);
			udpList.add(udp);
//			for (int j = 0; j < str3.length; j++) {
//				System.err.println("内容"+(j+1)+"="+str3[j]);
//			}
		}
		for (UdpServerVO udp : udpList) {
			System.err.println(
					"[id]="+udp.getId()+" [车牌号]="+udp.getLicensePlatel()+" [设备id]="
					+udp.getEquipmentId()+" [车主电话]="+udp.getPhone()+" [经度]="
					+udp.getLng()+" [纬度]"+udp.getLat()+" [速度]="+udp.getSpeed()
					+" [方向]="+udp.getDirection()+" [GPS时间]="+udp.getGpstime()
					+" [接收时间]"+udp.getReceivetime()+" [当日里程]="+udp.getDayMileage()
					+" [总里程]="+udp.getTotalMileage()+" [状态]="+udp.getState()
					+" [位置]="+udp.getPosition()+" [有效性]="+udp.getValidity()+" [sim卡号]="+udp.getSimCard()
					);
		}
	}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值