conversion of string to string array in java

Hi can any one explain to me how to convert this string to string array.
String record ="123,srini masi,229 WEST LOOP 121"
this my String i am getting this from database every time string value will be changed it is a dynamic value
i want to convert this String into below format.
String[] records = { "123", "srini masi", "229 WEST LOOP 121"}
LVL 2
srikoteshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

contactkarthiCommented:
String[] records = record .split(",");
0
srikoteshAuthor Commented:
if suppose my string will be like this
String record = "000123814    JOHN ADAM     229 WEST LOOP ";
now how can i split  if i go with space
String[] records = record .split(" ");
 i am getting wrong data because john adam i need to get as one and 229 WEST LOOP this value i have to get as one string.

can u suggest in this scenario
0
contactkarthiCommented:
how are you getting the string in the first place? is it a field in database or a combination of multiple fields?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

srikoteshAuthor Commented:
output is the column in database
that contains this value  000123814    JOHN ADAM     229 WEST LOOP
that column datatype is varchar(2000)
i need to get the value from that column assign to strignarray
0
contactkarthiCommented:
String[] records = record .split("\\s{2,}");

it will split if there are more than 1 space
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
0
Jeffrey Dake Senior Director of TechnologyCommented:
I would take a step back and look at how you are getting this string.  If you are using a result set to load the data from the database you should already be able to load each column into their own field.  

http://docs.oracle.com/javase/tutorial/jdbc/basics/retrieving.html
0
srikoteshAuthor Commented:
thanks karthi for ur help
now it is working fine. i am able to insert values into csv file.
thanks cehj for ur suggestion that way also we can do but we need to pass the latest idvalue  that is inserted in db,based on idvalue we can fetch output  column from the table.
0
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.