I am new to Java and have to implement below logic.
I have to read entire file (Approx. 50 MB)and and write a new file based on group by on invoiceNum(key) present in the file.

For example -

My file content is

```none
DETAIL|8834|2020-02-14|31|1964|abc|acb||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|32|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|33|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|34|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|35|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|36|1964|abc|abc||SG|SG|802|||||||1232.3700|8147DBD670B74E65A848|3584453|abc
DETAIL|8834|2020-02-14|34|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584455|abc
DETAIL|8834|2020-02-14|35|1964|abc|abc||SG|SG|802|||||||1200.0000|8147DBD670B74E65A848|3584455|abc
DETAIL|8834|2020-02-14|36|1964|abc|abc||SG|SG|802|||||||1232.3700|8147DBD670B74E65A848|3584455|abc

```

In this file content I have 2 invoice number (3584453 and 3584455)
So 1st 5 lines belongs to invoice number - 3584453 and all 5 lines should be copied to new file say test1.txt and remaining 2 lines belongs to invoice number - 3584455 and these 2 lines should be copied to new file say test2.txt

I will have around 15k lines in file and I should create new file for all unique invoice numbers. I am using jdk 7.

Could anyone please help with this logic?

Thank you.