How would I generate the output in Java with regex, split, or tokenizing? I need to remove the spaces around words and the commas between the words. I want to store this output and then jdbc will parse this data into the tables of my MySQL database.
-
I am thinking of using string[] because I have multiple rows of this kind of data.Which is one better?shilps– shilps2010-11-06 02:55:34 +00:00Commented Nov 6, 2010 at 2:55
-
@Adam: "The homework tag, like other so-called 'meta' tags, is now discouraged," but, shilps, please follow general guidelines, including stating specific restrictions, what you've tried so far, and what specifically is confusing you.Roger Pate– Roger Pate2010-11-08 17:29:47 +00:00Commented Nov 8, 2010 at 17:29
1 Answer
Since this is homework, I'm only going to give you HINTS. You then need to go away and try and code this yourself:
How would I generate the output
The simple way is to use String concatenation and System.out.println(...);
... if I have to do in java with Regex or split or tokenizer?
Either will work. Some ways are simpler than others. You figure out which. (It is important that you figure this out for yourself!)
I need to remove the " "around the words
If you need to do this after splitting, lookup String.trim().
... and , between the words.
You should already have done this with whatever it is you used to split the line into parts.
I want to store this output and then jdbc will parse this data into the tables of my database on mysql.
Do you need to do this? Does the homework question expect you to do this?
If you do, check your lecture notes / text book on how to use JDBC and SQL from Java. (I'm sure they won't have thrown you this question without giving you lots of material about this.)