arrays - Java dealing with commas in strings -


i have fixed strings like:

key(1,one,two,three,table1) key(1,cat,dog,bat,rabbit,table2) key(1,go,do,table3) 

i know fixed parts are:

  • the first 4 chars (until ,)
  • the last three

i interested words inside these 2 parts without commas , store in linkedlist. example: cat dog bat rabbit, or 1 2 three.

is there easy way rid of commas , store values in linkedlist?

list<string> list = new linkedlist<>(); (string key : keys){   string[] array = key.split(",");   (int i=1; i<array.length-1; i++){     list.add(array[i].trim());   } } 

or

list<string> tmplist = arrays.aslist(str.split(",")) list<string> list = new linkedlist<>(tmplist.sublist(1, tmplist.size()-1)); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -