Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Subject: extract the string before space

807605Aug 29 2007 — edited Aug 29 2007
I have a string say "aquarium a". i want to extract the string appearing before the space and discard the string appearing after space.
that is the resultant string required is "aquarium". any number of characters can appear after space.
is it possible to solve using replace() method. i cant hardcode space+character in replace method because number of characters after space is not known.
Is there any easy way to get the required result
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2007
Added on Aug 29 2007
9 comments
1,737 views