我有一个html文件,其中包含执行期间发生的异常的堆栈跟踪。现在我想从中获取异常并比较其堆栈跟踪的进一步发生。如果堆栈跟踪变化,我会增加它的数量。
目前我正在使用jsoup解析器从html文件中获取内容 我如何获得独特的例外情况和数量。附上到目前为止我所取得的代码
Elements elements = doc.body().select("pre");
int index1 = 1;
for (Element element : elements) {
System.out.println("\n\n\n" + links.get(index1).ownText());
Elements a = element.children().select("li");
boolean flag = true;
for(Element b : a){
exceptionText = b.ownText();
Pattern patternExcpetion = Pattern.compile("(.+?) (.*Exception.*)");
Matcher matcherException = patternExcpetion.matcher(exceptionText);
if((matcherException.find()) && (flag == true)){
System.out.println(matcherException.group(1));
ExceptionList.put(matcherException.group(1).replaceAll("(:)"," "),0);
flag = false;
}
Pattern pattern = Pattern.compile("(^.*Exception.*$)");
Matcher matcher = pattern.matcher(exceptionText);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
}
index1++;
}
示例HTML文件
[8/5/2014 2:46:11 AM] [Error]: <?xml version="1.0" encoding="utf-16"?>
<boolean>false</boolean>
This exception was caught:
System.Web.Services.Protocols.SoapException: Cannot complete login due to an incorrect user name or password.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at VMware.vSphere.VimService.Login(ManagedObjectReference _this, String userName, String password, String locale)
at DynamicOps.Vrm.Agent.vSphere.VSphereSession.Connect(String username, String password)
at DynamicOps.Vrm.Agent.vSphere.VSphereHypervisorServiceProvider.GetComputeResources(ManagementEndpoint managementEndpoint)
at DynamicOps.Vrm.Agent.vSphere.VSphereAgentService.GetHostClusterList()
at DynamicOps.Vrm.Agent.Core.VRMCoreAgent.SendPingReport()
at DynamicOps.Vrm.Agent.Core.CoreAgentBase.SendPingReportLoop(Object sender, ElapsedEventArgs e)
[8/5/2014 2:47:16 AM] [Error]: <?xml version="1.0" encoding="utf-16"?>
<boolean>false</boolean>
This exception was caught:
System.Web.Services.Protocols.SoapException: Cannot complete login due to an incorrect user name or password.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at VMware.vSphere.VimService.Login(ManagedObjectReference _this, String userName, String password, String locale)
at DynamicOps.Vrm.Agent.vSphere.VSphereSession.Connect(String username, String password)
at DynamicOps.Vrm.Agent.vSphere.VSphereHypervisorServiceProvider.GetComputeResources(ManagementEndpoint managementEndpoint)
at DynamicOps.Vrm.Agent.vSphere.VSphereAgentService.GetHostClusterList()
at DynamicOps.Vrm.Agent.Core.VRMCoreAgent.SendPingReport()
at DynamicOps.Vrm.Agent.Core.CoreAgentBase.SendPingReportLoop(Object sender, ElapsedEventArgs e)
[8/5/2014 2:48:19 AM] [Error]: <?xml version="1.0" encoding="utf-16"?>
<boolean>false</boolean>
This exception was caught:
System.Web.Services.Protocols.SoapException: Cannot complete login due to an incorrect user name or password.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at VMware.vSphere.VimService.Login(ManagedObjectReference _this, String userName, String password, String locale)
at DynamicOps.Vrm.Agent.vSphere.VSphereSession.Connect(String username, String password)
at DynamicOps.Vrm.Agent.vSphere.VSphereHypervisorServiceProvider.GetComputeResources(ManagementEndpoint managementEndpoint)
at DynamicOps.Vrm.Agent.vSphere.VSphereAgentService.GetHostClusterList()
at DynamicOps.Vrm.Agent.Core.VRMCoreAgent.SendPingReport()
at DynamicOps.Vrm.Agent.Core.CoreAgentBase.SendPingReportLoop(Object sender, ElapsedEventArgs e)
[8/5/2014 2:49:23 AM] [Error]: <?xml version="1.0" encoding="utf-16"?>
<boolean>false</boolean>
This exception was caught:
System.Web.Services.Protocols.SoapException: Cannot complete login due to an incorrect user name or password.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at VMware.vSphere.VimService.Login(ManagedObjectReference _this, String userName, String password, String locale)
at DynamicOps.Vrm.Agent.vSphere.VSphereSession.Connect(String username, String password)
at DynamicOps.Vrm.Agent.vSphere.VSphereHypervisorServiceProvider.GetComputeResources(ManagementEndpoint managementEndpoint)
at DynamicOps.Vrm.Agent.vSphere.VSphereAgentService.GetHostClusterList()
at DynamicOps.Vrm.Agent.Core.VRMCoreAgent.SendPingReport()
at DynamicOps.Vrm.Agent.Core.CoreAgentBase.SendPingReportLoop(Object sender, ElapsedEventArgs e)