paramList = new ArrayList<String>();
paramList.add(line.split(","));
When I used this, it gives me the error:
cannot find symbol
symbol: method add(java.lang.String[])
location: interface java.util.List<java.lang.String>
With this, I would get output in this manner: “abc” “bvc” “ebf” . Now can I use trim to get rid of ” “. So that the output becomes: abc bvc ebf
Input: “AAH196″,”17:13:00″,”02:49:00″,287,166.03,”Austin”,”TX”,”Virginia Beach”,”VA”
Output: AAH196 17:13:00 02:49:00 287 166.03 Austin TX Virginia Beach VA
I need to remove the ” “around the words and , between the words. I want to store this output and then jdbc will parse this data into the tables of my database on mysql.
paramList.add() wants a
Stringbutline.split(",")returnsString[]The two are not equivalent.
Maybe you want something like:
or
As for the added question, there are lots of ways to skin a cat.
If the words are ALWAYS surrounded by quotes then you can do something like:
This will remove the first and last char from the String. Which will always be the quotes.
If you need something more flexible (For instance this solution would ruin string that aren’t surrounded by quotes) then you should read up on
regexand java’sPatternclass to see what suites your needs.As for the solution that you provided, trim() will only remove surrounding whitespace.