?
Solved

arrays

Posted on 2001-09-17
2
Medium Priority
?
255 Views
Last Modified: 2010-03-31
using jsp, i have a servlet that queries a database and returns all of the database tables in a pipe delimited string.

my question is this: is there a way to split the string into an array (similar to the split method in javascript), or is there an easy way to iterate through the resultset in the servlet and return an array instead of a string.

is there a better way to do this alltogether? i'm open to suggestions.

if there are multiple answers that i adopt, i will add additional questions and/or increase the points.
0
Comment
Question by:msdixon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
kanthonym earned 400 total points
ID: 6487897
Yes, you can use the StringTokenizer class. This will pewrmit you to iterate through the string and parse out the contents based on the delimiter that your provide.


The following is one example of the use of the tokenizer. The code:

     StringTokenizer st = new StringTokenizer("this is a test");
     while (st.hasMoreTokens()) {
         println(st.nextToken());
     }
 
prints the following output:

     this
     is
     a
     test
 

Constructor Summary
StringTokenizer(String str)
          Constructs a string tokenizer for the specified string.
StringTokenizer(String str, String delim)
          Constructs a string tokenizer for the specified string.
StringTokenizer(String str, String delim, boolean returnDelims)
          Constructs a string tokenizer for the specified string.
0
 
LVL 9

Author Comment

by:msdixon
ID: 6488037
that's what i needed.

works like a champ.

thanks
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question