Anton K.
Anton K.

Reputation: 973

Parsing a text file

guys. I have a task and would like to hear your advice on implementation details.

I have a file which contains information about clients and their accounts.

FIRST_NAME=Joe
LAST_NAME=Bishop
RECEIPT.0.ID=123
RECEIPT.0.CURRENCY=USD
RECEIPT.1.ID=3654
RECEIPT.1.CURRENCY=EUR
.......................
CARD.0.TYPE=VISA
.......................

FIRST_NAME=Peter
LAST_NAME=Swalsky
...............

And so on. So I need parse this information into classes like Account etc. Shall I use Scanner class with certain match pattern and parse information step by step or there might be another elegant way to do that? Thank you so much in advance.

Upvotes: 0

Views: 794

Answers (1)

Jochen Bedersdorfer
Jochen Bedersdorfer

Reputation: 4122

This looks like a valid Properties file, so java.util.Properties might help. It can load those files.

Upvotes: 7

Related Questions