This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes copying string to string array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "copying string to string array" Watch "copying string to string array" New topic

copying string to string array

Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
i have a list of strings in file.
eg: values of Pid(is unique) and PC(can be more than 1)
10 items
i opened the file. read each line to get string in. using subsrtring i store value in string1 and string2 till end of line. i loop it till end of file.
Question is how to copy this string1 to a new string array- arr1Pid? same with string2- array arrayPc. I want to sort array_Pc. Please let me know how to do this one! thanks
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

It is probably easier to use Collections such as List or Set, depend on your need. If you want to keep the relationship between the PID and the PC, you might want to use Map. Those interfaces has the sorted implementation.
and you can do toArray() when you are done processing if you really need them in array format.
Check out javadoc on Collections and Map.
I agree. Here's the link:
subject: copying string to string array
It's not a secret anymore!