H开发者_JAVA技巧ow 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.
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.)
精彩评论