Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Splitting strings

Thread view: 
davidjohnlong@googlemail.com - 30 Mar 2006 12:03 GMT
Hi

Wondered if anyone can help

I'm trying to split the following string into various different
section?

BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
2*Cream,2*Vanilla,*,*,2*Whisky

after : first varible
then 2nd, 3rd, 4th 5th after comma

(trying in impliment RFC 2324... )

Thanks
Alex Hunsley - 30 Mar 2006 12:48 GMT
> Hi
>
[quoted text clipped - 12 lines]
>
> Thanks

Use StringTokenizer.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html

This sort of question is more suited to comp.lang.java.help as it's a
simple question. Also you could have tried googling for "java string
splitting" or similar, which would probably have given you the answer.
IchBin - 30 Mar 2006 16:11 GMT
>> Hi
>>
[quoted text clipped - 19 lines]
> simple question. Also you could have tried googling for "java string
> splitting" or similar, which would probably have given you the answer.

Or take a look at String Class Split(). I think Sun is moving away from
StringTokenizer.

String[] stringVar.split(String regex)  Splits this string around
matches of the given regular expression.

String[] stringVar.split(String regex, int limit) Splits this string
around matches of the given regular expression.

Then you use the the new 1.5 The For-Each Loop.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
Oliver Wong - 30 Mar 2006 16:23 GMT
> Hi
>
[quoted text clipped - 10 lines]
>
> (trying in impliment RFC 2324... )

   Are you expecting the the above as one long string? Note that the ':'
appears twice in it.

   I'd expect some newline characters to be present, as in:

<2324 request>
BREW coffee://localhost/pot-1
HTCPCP/0.1
accept-additions: 2*Cream,2*Vanilla,*,*,2*Whisky
</2324 request>

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.