I'm writing Java code. I have files that looks like:
- President and Vice-President ==> Fred Flinestone(P)
- US Senate ==> Louise Moon (P)
- Proposition #1 ==> Yes
- Amendment #1 ==> Decline
I am trying to separate the different contest (President and Vice-President, US Senate, etc.) from the "voter's choice" (Alvin Boone..., Louise, etc) line by line. I want to use the first token to create an array list and the second token to be added to the corresponding array list.
I hope I am not over my head with this as I am a new Java programmer but all help is appreciated. So far I have.
public void go () {
getContest();
}
void getContest() {
// reading file and call the addContest() method for each line/
try {
String line = null;
while ((line = reader.readLine()) != null) {
addContest(line);
}
}
}
void addContest (String lineToParse) {
String[] tokens = lineToParse.split(">");
// somehow this will add contests to
// its own array 0 is the first part of split
contestList.add(tokens[0]);
}
I hope I am not asking for too much but if I can find out how to create the array list I am sure I can put second token in the corresponding array. Thank you!