Hi I have log files of the following pattern-
2014-03-06 03:21:45,432 ERROR [mfs:pool-3-thread-19] dispatcher.StatusNotification - Error processing notification. Operation aborted.
java.sql.SQLException: Network error IOException: Connection timed out: connect
2014-03-06 03:22:06,454 ERROR [mfs:pool-3-thread-19] dispatcher.ClientStatusNotification - Error processing notification. Operation aborted.
java.sql.SQLException: Network error IOException: Connection timed out: connect
2014-03-06 03:22:27,462 ERROR [pool-1-thread-1] cluster.ClusterServiceImpl - unexpected error when trying to update LastCheckinTime
java.sql.SQLException: Network error IOException: Connection timed out: connect
...
I am trying to split the string into substrings such that-
parsedString[0]=2014-03-06 03:21:45
parsedString[1]=,432 ERROR [mfs:pool-3-thread-19] dispatcher.StatusNotification - Error processing notification. Operation aborted.
java.sql.SQLException: Network error IOException: Connection timed out: connect
parsedString[2]=2014-03-06 03:22:06
....
I tried using string.split(datepattern) but it only gives me the content in the string array and not the dates.
I also tried using Pattern matcher but it only gives me a list of matching dates and not the content.
How do I get both values into the same string array. Any help would be much appreciated. Thanks
Edit- String pattern="([0-9]{4}-[0-1][0-9]-[0-3][0-9]\s(?:[0-1][0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9],)"; String parsedLogMessage[]=GetLogString().split(pattern); this.MessageContent=Arrays.asList(parsedLogMessage);
This only gives the string split by regex and not the regex string itself