I'm looking for an efficient way to split a text file into a set of ArrayList. The text file is a Thread dump and I'd like to create a List for every single Thread. Every thread is separated by an empty line. For example, taken the following file:
"management-handler-thread - 66" prio=10 tid=0x00007fe960111000 nid=0x4cea waiting on condition [0x00007fe96c25c000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006019cbbd0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
"management-handler-thread - 65" prio=10 tid=0x00007fe968185800 nid=0x4ce9 waiting on condition [0x00007fe96c35d000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006019cbbd0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
The first List should contain:
"management-handler-thread - 66" prio=10 tid=0x00007fe960111000 nid=0x4cea waiting on condition [0x00007fe96c25c000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
. . .
And the second List should contain:
"management-handler-thread - 65" prio=10 tid=0x00007fe968185800 nid=0x4ce9 waiting on condition [0x00007fe96c35d000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
. . . .
What would you recommend to do that ? (Iteration, Regular expression ..) Thanks