• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with getting the first 10 values from a string

 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again
I have a string with 30 strings inside it.
how can i get the first 10 values out use them in a part of my code. then get the next 10 values out and use them in a diffrent part of my code, and so on with the last 10 values? also i have blank strings inside the string so i cannot use the substring method as it does not allow blank strings.
could someone please help me
thanks ben
 
Manish Hatwalne
Ranch Hand
Posts: 2595
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are these strings inside the string separated?
I believe, you'll need java.util.StringTokenizer.
- Manish
 
Irene Loos
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use something like this:

[ January 14, 2003: Message edited by: Irene Loos ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "blank string"? Do you mean an empty string (i.e. "")? Or do you mean a space character (i.e. " ")? I think the above answer assumes that you meant the first. However, if you mean the second, you surely can use substring(). It would be easier to use StringTokenizer, though.
HTH
Layne
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben:
If you have blank strings, how do you know their locations? A blank string can be anywhere, since it doesn't take up space.
So if you just need 10 strings, it is ok. Otherwise, how do you know they are the first 10 strings? The very first string could be a blank.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic