File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
It is sorta covered in the JavaRanch Style Guide.
subject: copying string to string array
It's not a secret anymore!