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