java - File Reading and Processing -


i stuck on how should go reading/processing file.

example file:

  2    cow   moo   black   , white fast    pig   pink   slow 

the 2 indicates number of entries in file. blank line. name of object , 2 lines of characteristics.

basically i'm confused best way go reading input line line , processing can create designated object.

i thinking can create arraylist , go there don't know how blank line delimiters taken. , since number of elements different every file, i'm unsure how take account.

it sounds issue more on conceptual level syntax level try answer @ level.

first don't think number @ start required, can use check on track after fact.

i think should create class describes objects, lets call "animal" class reference. constructor should take array list contains subset of lines relevant 1 particular animal (the 1 instantiating). properties class should whatever require (e.g. name, etc..).

so in pseudo-code:

prep array list:

-read each line of file arraylist 

consume arraylist:

-read , save off number of entries checking later -read , ignore first blank line -read line line arraylist until next blank line, pass new array list constructor animal class , repeat until hit end of file (making sure construct final object well). 

"animal" constructor:

-set first entry in arraylist passed constructor animals name. -set remaining properties required.... 

as create animals can store them in array , @ end can validate created correct number value stored off @ start.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -