Java关于Log文件的读取的问题,请教该怎么实现?
有一个比较大的log日志文件,内容如下:2011-12-19 11:18:17.585+0800,INFO,,,,,,"0020-112002-AWDM: trace---para,start,Fri Sep 30 00:00:00 CST 2011,",,
2011-12-19 11:18:17.585+0800,INFO,,,,,,"0020-112002-AWDM: trace---para,end,Wed Nov 30 00:00:00 CST 2011,",,
2011-12-19 11:18:17.585+0800,INFO,,,,,,"0020-112002-AWDM: trace---para,indexFrom,0,",,
2011-12-19 11:18:17.585+0800,INFO,,,,,,"0020-112002-AWDM: trace---para,findCount,100,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---enter,ConvertListToLMJobLogEntityList.,convert,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: -------DB Data List start-------------------------------------------,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---data,i=0,AutoNumber=405090,ModelCode=NC100376,SerialNumber204318,JobID=5490,JobDetailType=609,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---data,i=1,AutoNumber=405091,ModelCode=NC100376,SerialNumber204318,JobID=5489,JobDetailType=609,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---data,i=2,AutoNumber=405093,ModelCode=NC100376,SerialNumber204318,JobID=5495,JobDetailType=306,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---data,i=3,AutoNumber=405094,ModelCode=NC100376,SerialNumber204318,JobID=5492,JobDetailType=306,",,
2011-12-19 11:18:20.749+0800,INFO,,,,,,"0020-112002-AWDM: trace---data,i=4,AutoNumber=405107,ModelCode=NC100376,SerialNumber204318,JobID=5521,JobDetailType=609,",,
......
......
我要实现的功能就是,这个Log文件中的某些特定行中得AutoNumber值是否有重复的,找出重复的。
大致思路如下:
首先去读每一行,然后进行字符串匹配,即判断每一行中是否含有上面蓝色的字符串"trace---data,i=",如果有,就需要对该行进行处理,即将该行的AutoNumber的值作为Key值放进HashMap中(红色数值),如果不包含所需字符串,则不处理。然后读下一行,继续往Map中放AutoNumber值,如果Map中Key值存在了,则print该值,并说明该值已存在。最后循环下去...这样我就能找出其中重复的AutoNumber值了。
不过具体代码写不好,求高人给出关键的代码,谢谢了。
[ 本帖最后由 章文2010 于 2011-12-19 22:28 编辑 ]