2
我想读用Java写在这个形式的日志文件:像这样解析文本/安排在日志文件中的文本
2 05.08.2011 13:07:54.136 .r5 objects - ODBC [128] - C:\Windows\example.r5 [30] - 0x081BF015 - TLineThread.ModuleODBC the ODBC driver reports an error - parameter strSQLError contains the error information
1 09.08.2011 19:01:28.473 .r5 objects - ODBC [27] - C:\Windows\ExampleWithALongName.r5 [18] - 0x081BF015 - ODBC driver reports an error - parameter strSQLError contains the error information
什么的WIRTE它的输出:
2 05.08.2011 13:07:54.136 .r5 objects - ODBC [128] - C:\Windows\example.r5 [30] - 0x081BF015 - TLineThread.ModuleODBC the ODBC driver reports an error - parameter strSQLError contains the error information
1 09.08.2011 19:01:28.473 .r5 objects - ODBC [27] - C:\Windows\ExampleWithALongName.r5 [18] - 0x081BF015 - ODBC driver reports an error - parameter strSQLError contains the error information
因此,在每一行中,分隔符“ - ”恰好在之前行的分隔符“ - ”之下。 (如果路径名称更长或不同,则不需要mather)
我应该怎么做?
如果只想改造文本(没有其他操作)我建议你不要使用java的。例如在Linux中,你可以去cat testLinens.txt |列-t -s“”和它的工作原理(testLines.txt是您的示例1中的行) – hovanessyan