Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what am I missing?

 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've already tested the file scanner which takes a few seconds to scan the whole file. This is stalling, just blinking the cursor while nothing happens...

 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not clear what you're asking. What do you expect the program to do that it's not doing?
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add some of System.out.println and to see where you stop.
 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually the code was fine. it just took a lot longer to run than my test code. the cursor was blinking on an empty screen for so long that i thought it wasnt running right. i made it print out each set of tokens while it's running. now it's been running fine for over a minute, but it's still in the B's. thanks :roll:
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse,

1) I bet you've heard at least once that using StringBuffer (or the JDK 1.5 StringBuilder) is better than using String and the "+" operator. This program is absolutely one of those times. If you made tokenList into a StringBuffer (or StringBuilder) and used separate "append()" calls instead of each "+" operation, you'd have a noticeable speedup.

2) Another probably large performance improvement could be gotten with buffered I/O. Replace the Scanner allocation with

new Scanner(new BufferedReader(new FileReader("Websters_1913_Dictionary.txt")));

... and you should notice a large speedup.

3) Your signature is hella confusing -- I thought it was part of your question, originally, which really confused me, as I couldn't see where any of that output was supposed to come from. I'd change it if I were you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic