Java-如何仅读取输入流的某些部分
|
我有一个需要解析输入文件并仅读取文件某些部分的要求。我有一个日志文件,其中包含不同级别的信息警告和错误。现在,我只需要阅读包含完整错误堆栈跟踪的部分。我如何使用Java实现此目的。
例如:
INFO | 2011-04-13 17:59:22,810 | Calling Feedback from 127.0.0.1
INFO | 2011-04-13 17:59:24,920 | Successfully called Feedback from 127.0.0.1
INFO | 2011-04-13 17:59:31,561 | FeedBackList
ERROR | 2011-04-13 19:00:41,640 |
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:228)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy309.getConsumerProfileData(Unknown Source)
at com.scea.usps.model.service.impl.AccountSettingsServiceImpl.getUserProfile(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy284.getUserProfile(Unknown Source)
at com.scea.usps.model.common.PsninfoUtility.getTop3Generes(Unknown Source)
at com.scea.usps.model.common.PsninfoUtility.updatePsnInfoDetail(Unknown Source)
at com.scea.platform.framework.api.PsnInfoThread.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
INFO | 2011-04-13 17:59:22,810 | Calling Feedback from 127.0.0.1
INFO | 2011-04-13 17:59:24,920 | Successfully called Feedback from 127.0.0.1
INFO | 2011-04-13 17:59:31,561 | FeedBackList
在上面的日志中,我需要提取(读取)从ERROR开始的所有行,直到堆栈跟踪结束。请就此分享您的想法。谢谢。
没有找到相关结果
已邀请:
5 个回复
翰冒绢县
砷竣阿
樊熄忙暖
诫商
驮帽俺篮号