jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Stringtokenizer values. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Stringtokenizer values." Watch "Stringtokenizer values." New topic

Stringtokenizer values.

Charles Jefferson

Joined: Mar 25, 2009
Posts: 2
Hello. I have been lurking around here getting tips and advice for quite some time: it's greatly appreciated. I am, however, stumped, and need some help using Stringtokenizer. I will comment parts of code to keep it confidential, but what is posted should explain:

In essence, why is songtitle[] not printing?
Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
I suspect you are getting a StringIndexOutOfBoundsException, Try putting a System.out.println(" exception" ); in your catch block and see what happens.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
Welcome to JavaRanch

Have you been told to use StringTokenizer? It is described here as legacy code and users are "discouraged" from using it in new code.

You can get individual lines from a text file by various techniques; I think the Scanner#nextLine() method might be the simplest. Then you can use the java.lang.String#split method to separate it into words.
You can do all sorts of things with those words, even putting them into a java.util.Set<String> which has a contains method.
Charles Jefferson

Joined: Mar 25, 2009
Posts: 2
I am not required to do anything; this is a personal project I'm working on. The problem I had was finding a way to do this. I am currently taking a JAVA class and they are fans of using the Princeton Standard Libraries to try to "simplify" things...meanwhile, it's not convenient when trying to do slightly more difficult things.
I agree. Here's the link: http://aspose.com/file-tools
subject: Stringtokenizer values.
It's not a secret anymore!