473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

StringTokenizer question

Hi,

I'm having a little problem with the string tokenizer. For example, I got
this data string :
"0#0#0#0####0#0#0#.. and so on....."
How obvious, the # char will be the delimiter. But as you can see, at some
points there are two or more brackets pasted together. I want to let the
program return an empty string but the tokenizer just passes these brackets.
How to tell him he got to give the empty places as well?

Greetings,
Rick
Jul 17 '05 #1
2 3789
One of the constructors for StringTokenizer has a boolean indicator
that tells it to return the delimiters as well. You could use that
contructor, then in your code loop, you can discard the delimiters,
but keep a flag so you can catch the condition where you get two
tokens in a row. In that case, you can process an empty string.

Bill Dennis
Jul 17 '05 #2
"Rick" <as******@hotmail.com> wrote in message news:<3f***********************@news.xs4all.nl>...
Hi,

I'm having a little problem with the string tokenizer. For example, I got
this data string :
"0#0#0#0####0#0#0#.. and so on....."
How obvious, the # char will be the delimiter. But as you can see, at some
points there are two or more brackets pasted together. I want to let the
program return an empty string but the tokenizer just passes these brackets.
How to tell him he got to give the empty places as well?

Greetings,
Rick

If you check in the documentation IIRC you'll find an extra parameter
which can be used to tell StringTokenizer to return the delimiters as
well as the tokens. Using this, plus a little extra work, it is
possible to figure out whether two delimiters have been passed in a
row, without any token in between, and treat this case as an empty
token.

One final thing to note is an issue if the string ends with a delimiter,
make sure you handle the implied empty token which 'follows' it. You
could do this by always appending a '#' (the delimiter) onto the end of
the tokenized string, so any implied empty token at the end of the string
could be processed without need to write special case code to detect it.
-FISH- ><>
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: - Steve - | last post by:
It doesn't appear that Visual Studio 2003 has the StringTokenizer class for a J# project. Am I missing something? Steve
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
5
by: Carlitos | last post by:
Hi there, What would be the counterpart for Java's StringTokenizer class in .NET? In fact, does anybody know a good web site that gives this kind of information, like a Java-.NET/.NET-Java...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
1
Ganon11
by: Ganon11 | last post by:
Hey, Last year I was working in Java, and one of the predefined classes we used was the stringTokenizer.java class. I wanted to use this in C++, but couldn't find a predefined class. So I made...
2
by: Bilwin | last post by:
Hi friends, How can i convert StringTokenizer to string array? friends please reply me..
6
by: js06am | last post by:
The API specification for the Java 2 Platform Standard Edition 5.0 states that the class StringTokenizer is 'a legacy class.' What does this mean? a.m.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.