File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes what am I missing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what am I missing?" Watch "what am I missing?" New topic
Author

what am I missing?

Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

I'm not clear what you're asking. What do you expect the program to do that it's not doing?


[Jess in Action][AskingGoodQuestions]
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
add some of System.out.println and to see where you stop.
Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what am I missing?