我有一个文本文件,我需要根据标识符读取它并将其分组并创建多个文本文件。我在早期的项目中使用了 RandomAccessFile、Filereader,但我需要您提供线索来实现以下要求。如果我获得基于一般详细信息对记录行进行分组的逻辑,我将能够编写代码。
Collateral.txt
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
机械详情|S|!|!|66T4051|N|MACH|123|55| 附加抵押品详情|66T4051|N|01|__14P|
General Details 是父键。在一般细节下,根据条件收费细节,机械细节,保险细节和其他细节将被包括在内。
我需要将一个一般详细信息部分分组并创建新文件。让我们说。
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||| | |
等等...
请帮我找出我需要使用哪个文件阅读器以及如何实现逻辑。分隔符将是每一列的管道,分隔符将是每一行的结束行。