Current Position:Home > How to convert a tokens from Stringtokenizer to ArrayList

How to convert a tokens from Stringtokenizer to ArrayList

Update:11-30Source: network consolidation
Advertisement
I have a string example abc,xqy
delimiter is ,
i get tokens using StringTokenizer.
I want to create a ArrayList of these tokens. How can i do it?
thanks,

The Best Answer

Advertisement
StringTokenizer st=new StringTokenizer(Sup_Email1, ",");
ArrayList list1 = new ArrayList();
System.out.println("the tokens got here in while are:"+st.countTokens());
for(i=0;i<=size;i++){System.out.println("inside for");
while(st.hasMoreTokens()){System.out.println("inside while");
     list1.add(st.nextToken());
     }//end of while
}//end of for
for(Iterator iter=list1.iterator(); iter.hasNext();){
     System.out.println((String)(iter.next())); //---------gives me only 1st token
what's wrong here/
  • How to convert a tokens from Stringtokenizer to ArrayList Update:11-30

    I have a string example abc,xqy delimiter is , i get tokens using StringTokenizer. I want to create a ArrayList of these tokens. How can i do it? thanks,StringTokenizer st=new StringTokenizer(Sup_Email1, ","); ArrayList list1 = new ArrayList();

  • How to avoid links/paths get converted into tokens in teststand report Update:11-30

    Hi,  I was trying to get The hyperlink for some of The files in The teststand(4.0) report for a particular custom step made in labview 8.5. I was able to get The link correctly when The path specified does not contain any tokens(\N, \T,\R,\n,\t,\r,et

  • How to Convert the Stream of strings into ArrayList Integer Update:11-30

    I have a String st = "12 54 456 76ASD 243 646" what I want to do is print it like this from the ArrayList<Integer>: 12 54 456 243 646 It should catch the "76ASD" exception as it contain String Character. This is how I am doing, w

  • A line of text, tokenizing it using StringTokenizer Update:11-30

    Hello, I feel I'm going round in circles, what I have is a line of text a mobile message like these 25 100 SEND 2228161 Hello Pete RECEIVE 2228161 Hello Chris, how are you? SEND 2227765 I hate text speak RECEIVE 2228876 wot u on bout SEND 2227975 The

  • Using StringTokenizer to jump to a specific token Update:11-30

    Hi all, I have a StringTokenizer which is splitting on ",". I want to append some text after the nth column (e.g. 2) is there a way of going to the 2nd column directly and appending some text? e.g. String test = a,b,c,d,e,f,; StringTokenizer tok

  • A little help with tokenizing a string Update:10-11

    Have most of this working and i will add the code to the end of the for you all to look at. Essentially what i am trying to do is tokenize a string that looks like: program int ABC, D;      begin read ABC; read D;           while (ABC != D) begin    

  • Speed of StringTokenizer Update:11-30

    I am using a tokenizer to parse a very large string. Is there any way to improve the performance StringTokenizer? I am attempting to parse a string with about 200 tokens. I convert the tokens to integers using Integer.parseInt(). It takes a second to

  • Missing Value using HashMap and StringTokenizer Update:10-11

    class StringToken      String Message = "a b Germany";      HashMap <String,String> map; StringTokenizer token;      public StringToken()           try           token = new StringTokenize(Message);                map = new HashMap <Str

  • How to Look at current Token Update:10-11

    When using the tokenizer in Java I see that you can count tokens "countTokens() " , see if a string has more tokens "hasMoreTokens()", etc. But how do you work with the current token? For example: while ((str = in.readLine()) != null )

  • Guys I need some help. String token of a wired message Update:10-11

    well this is my code. code: import java.*;import java.util.StringTokenizer;import java.io.*; class stringtoken {         public static void main(String[] args) {         Runnable daemonRunner = new Runnable()        {                public void run()