aspose file tools*
The moose likes Java in General and the fly likes help with getting the first 10 values from a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "help with getting the first 10 values from a string" Watch "help with getting the first 10 values from a string" New topic
Author

help with getting the first 10 values from a string

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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

Joined: Sep 22, 2001
Posts: 2578

How are these strings inside the string separated?
I believe, you'll need java.util.StringTokenizer.
- Manish
Irene Loos
Ranch Hand

Joined: Apr 15, 2002
Posts: 78
You can use something like this:

[ January 14, 2003: Message edited by: Irene Loos ]

Irene Loos
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with getting the first 10 values from a string
 
Similar Threads
help with some code.
Object creation
Question regex
another NullPointerException problem
can you put multiple words in a database by using one statement