Read text file based on identifier and create another set of text file
<p>I have a text file which i need to read based on identifier and group it and create number of text files. i have used RandomAccessFile, Filereader in my earlier project but i need clue from you to achieve below requirement. i will be able to write the code if i get logic to group the line of records based on General Details.</p>

<h2>Collateral.txt</h2>

<pre><code>General Details|S|!|!|66T4049|N|
Charge Details|S|!|!|66T4049| 3825|
Charge Details|S|!|!|66T4049| 3826|
Machinery Details|S|!|!|66T4049|N|
General Details|S|!|!|66T4050|N|
Immovable Property Details|S|!|!|66T4050|N|
US_CIPD|66T4050|N|S156284|02-01-2013 00:58:50|
General Details|S|!|!|66T4050|N|IMUSD|I||| | |
Immovable Property Details|S|!|!|66T4050|N|IMUSD|
US locale Immovable Property Details|66T4050|N|
General Details|S|!|!|66T4051|N|MACH|M||| | |
General Details|S|!|!|66T4051|N|MACH|M||| | |
Charge Details|S|!|!|66T4051| 3827|N|        
Charge Details|S|!|!|66T4051| 3828|N| 
Insurance Details|S|!|!|66T4051|   1|Y|
Insurance Details|S|!|!|66T4051|   2|Y|
Inspection Details|S|!|!|66T4051| 1846|N|
Inspection Details|S|!|!|66T4051| 1845|N|
Ownership and Tenancy Details|66T4051|  329|0
Ownership and Tenancy Details|66T4051|  328|0
</code></pre>

<p>Machinery Details|S|!|!|66T4051|N|MACH|123|55|
Additional Collateral Details|66T4051|N|01|__14P| </p>

<p>General Details is the parent key. under general details, based on condition charge details, Machinary details , Insurance details and other details will be included.</p>

<p>I need to group one general details section and create new file. lets say.</p>

<pre><code>Collateral1.txt
General Details|S|!|!|66T4049|N|
Charge Details|S|!|!|66T4049| 3825|
Charge Details|S|!|!|66T4049| 3826|
Machinery Details|S|!|!|66T4049|N|


Collateral2.txt
General Details|S|!|!|66T4050|N|
Immovable Property Details|S|!|!|66T4050|N|
US_CIPD|66T4050|N|S156284|02-01-2013 00:58:50|


Collateral3.txt
General Details|S|!|!|66T4050|N|IMUSD|I||| | |
Immovable Property Details|S|!|!|66T4050|N|IMUSD|
US locale Immovable Property Details|66T4050|N|


Collateral4.txt
General Details|S|!|!|66T4051|N|MACH|M||| | |
</code></pre>

<p>and so on...</p>

<p>please help me out which file reader i need to go for and how i can implement the logic. delimiter will be pipe for each column and delimiter will be end line for each row.</p>
