mercredi 13 septembre 2017

Chunk data between two words from a text file in java

I have a .txt file where the data is in following format.

Start-enclosure
Standard
African Safari Enclosure
09am
05pm
Ram
Safari Enclosure for animals requiring large roaming area
30
Start-animl
Elephant
400

Giraffe
350

Lion
300
End-enclosure


Start-enclosure
Premium
Standard Australian Enclosure
09am
09pm
Shyam
Standard Enclosure for animals available in australia
30
5
Start-animl
Koala
8

Wormbat
25

Wallaby
20
End-enclosure

I want to store this data in a List<Enclosure> Like using switch case for the type (Standard, Premium) and storing data in this format

Enclosure Name
Opening Time
Closing Time
Enclosure Manager
Description
Entry Price

List<Animals> { animal name, animal weight }

How can I achieve it. I was hoping some way to chunk data between Start-enclosure and End-enclosure and looping from the data. But how do I achieve it I am trying it but I need a direction to go straight path.

Aucun commentaire:

Enregistrer un commentaire