• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stringtokenizer values.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 82
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect you are getting a StringIndexOutOfBoundsException, Try putting a System.out.println(" exception" ); in your catch block and see what happens.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic