The Artima Developer Community
Sponsored Link

Java Answers Forum
testing for null spaces

1 reply on 1 page. Most recent reply: Nov 27, 2002 12:23 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
ben

Posts: 57
Nickname: loftty
Registered: Oct, 2002

testing for null spaces Posted: Nov 27, 2002 9:59 AM
Reply to this message Reply
Advertisement
i have this code which is below but it will not test to see if between 2 delimeters is a empty string or not.
all it does is to test the first and last tokens.
how do i test to see if there is a string between 2 delimeters or not and if there is not i would like it to go into a vector.
but i still want the code below
any ideas please
thanks
ben
while (s.hasMoreTokens()) {
token = s.nextToken();
if (lastToken){
if (token.equals(",")) {
v.add("");
}
lastToken = false;
}
if (! token.equals(",")) {
v.add(token);
}
}
if (token.equals(",")) {
v.add("");
}


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: testing for null spaces Posted: Nov 27, 2002 12:23 PM
Reply to this message Reply
I think adding the whitespace characters (" \t\n\r\f") to your delimiter set (when you instantiate the StringTokenizer) may do the trick.

Flat View: This topic has 1 reply on 1 page
Topic: Help Previous Topic   Next Topic Topic: implementation file!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use