aspose file tools*
The moose likes Java in General and the fly likes String to Array of String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "String to Array of String" Watch "String to Array of String" New topic
Author

String to Array of String

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Hi
How to convert String to Arrayof String
for Eg. String mstrString ="this is the test string";
after converting
the value of mstrString will be assinged to strArr vaiable.
String strArr[] = { -- value of mstrString --};

i have a String and i want to pass the Array of String into the Array.sort(String[]) methode.

how can i do this ,


Please help me for this
pinky yadav
Ranch Hand

Joined: Jun 17, 2002
Posts: 44
its not very clear what you want to do actually.
but if you want to convert string to array of string like this

then you can use StringTokenizer which will extract the works for you from the string and then you can put it in array of string.
[ August 11, 2004: Message edited by: pinky yadav ]
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Hi,
My intenstion is i have a string object and i want to convert this String object into ArrayofString object so that i will pass this ArrayofString object to sort method.

Let us see the Practical scenario
String mstrString = " this is the test string and want to convert it into array of String";
The output is it will return the Array of String
the function looks like

public String[] StringtoArry(String)
{
return String[];
}
}
pinky yadav
Ranch Hand

Joined: Jun 17, 2002
Posts: 44
if you want whole string as one entry in array then do


if you want each word as seperate word in array then
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
hi
Pinky Thanks for the same

I am writing the Webservice and this service will return the nuber of distincet word in the string , i done this by using this
Tom Hill
Ranch Hand

Joined: Aug 24, 2003
Posts: 115
StringTokenizer is a legacy class according to the 1.4.2 API.
You should use String.split(regex).

So to split a sentence up into an array of words:



Hope that helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String to Array of String