-3

How to add tokens to an arraylist in java? I want to add tokens to an array list.

StringTokenizer st = new StringTokenizer(line, ":Mode set - Out of Service In Service");
    while(st.hasMoreTokens()){
    out.println(st.nextToken());
Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
Ricky
  • 2,323
  • 6
  • 22
  • 22
  • When do you want to add them? While iterating through the loop? Please edit your question to be more specific, describing exactly what you are trying to accomplish, and what problems you are having while achieving that. – Merlyn Morgan-Graham Jul 01 '11 at 04:38

1 Answers1

1
List<String> list = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(line, ":Mode set - Out of Service In Service");
while(st.hasMoreTokens()){
  // out.println(st.nextToken());
  list.add(st.nextToken());
}
Landei
  • 54,104
  • 13
  • 100
  • 195
jasonk
  • 969
  • 5
  • 9