Parsing Character Stream
<p>I am getting a continuous stream of characters which I have moved into a flat file in a single line. Now these characters are coming in below form.</p>

<pre><code>keepalivekeep_aliveenroll,10.213.17.4,0,12,594,4,5,METRO-A,1enroll,10.213.17.4,0,13,594,4,5,METRO-B,1clear,10.213.17.4,0,14,100010934,1323168443
</code></pre>

<p>What i want is to move messages coming between particular tags (<code>keep_alive</code>, <code>clear</code>, <code>enroll</code>, etc.) in different lines. For example output from above should be:</p>

<pre><code>keep_alive      
keep_alive                                                                        enroll,10.213.17.4,0,12,594,4,5,METRO-A,1
enroll,10.213.17.4,0,13,594,4,5,METRO-B,1
clear,10.213.17.4,0,14,100010934,1323168443
</code></pre>

<p>What is the best way to do this in Java? What is noteworthy here is that file is getting continuous data and I need to do this continuously in some kind of loop.</p>
