Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using stringtokenizer

807569Jul 7 2006 — edited Jul 7 2006
I have a method in a class , which returns a String.
This string is sql statement, which could be one or many in number.

I want to write a method, by which if there is one statement, it returns the statement. If there are multiple statements, then return each one at a time. How do I do this?
public String getSql() {
			String insertSql = getInsertSQL();
			logger.debug("retrieved sql from dao >>>>>>>" + insertSql);
			StringTokenizer st = new StringTokenizer("+");
			if(st.countTokens()>0) {
				for(int i=0;i<st.countTokens();i++) {
					insertSql = (String) st.nextElement();
					logger.debug("retrieved sql from dao after tokanization >>>>>>>" + insertSql);												
				}
	 	 	}
	 	 	return insertSql;	 	 	
	 	 }	 
I tried something like this: This would only give me the last token. How do I get each of the sql, but only one at a time?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2006
Added on Jul 7 2006
1 comment
110 views