File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Tree Node --Word Tree

 
Taylor Woods
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I just learned basic stuffs about Tree Node, and I managed to fisnish my first simple program using Tree. Now, I'm challenging second tree program, and it's extremely hard for me...

The direction for this program is as shown below:


The book says that I need to use
%java WordTree"text.txt"count.txt to run this program.
--"text.txt" is the text file that the data is stored.

And...even though I did as the book showed, it keeps showing me errors
that say:



and


Could anyone show me how to fix those errors or show me another way to
creat this program?

Thank You for regarding my question.
And I will appreciate if anyone could give me some help.

Thank you. I hope you have a nice day.
[ March 28, 2005: Message edited by: Taylor Woods ]
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you may have forgotten to block the "else" clause. Try:



Henry
[ March 28, 2005: Message edited by: Henry Wong ]
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As well, Integer doesn't have a no-argument constructor.
 
Taylor Woods
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, David and Henry!! After following you guys' instructions, it seems to work. However, there is one problem. For this code, I need to use specific text file and specific command...

What if I want to put the data in this main code istead of putting it in the specific text file so I don't have to use that specific command?

Could you tell me which part I'm supposed to change and how I'm supposed to change? I'm sorry that I'm bothering you too much. Thank you so much.
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Taylor Woods:
What if I want to put the data in this main code istead of putting it in the specific text file so I don't have to use that specific command?
I don't follow. You already have it such that the user can specify the input and output file names. Do you want them hard-coded into the class? If so, just define constants instead of using args[0] and args[1], but that's probably not what you mean.

And what command? The "java WordTree" command? You could create a batch file called wordtree.bat:
 
Taylor Woods
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But...I don't know exactly how I should declare the String input in this code. And what do you mean by defining constants? Is it what I just asked you about? If so, how do I do it using args[0] and args[1]?

Since I don't quite understand this code, I hope you could show me exactly how the codes should be.

Oh...and last question~ if I'm going to specify the input file and use it to run the program, how do I run it? It seems to compile ok...but it shows this messayge:

WordTree.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Tool completed successfully

and it doesn't run if I use normal way to run this
which is:

c:\java\bin\java WordTree


If I run this using "c:\java\bin\java WordTree", it syas that

Usage: Word Tree inputfile & outputfile


How can I run this program properly?

Thank you so much for your consideration and help, David. I truly appreciate it.

[ March 29, 2005: Message edited by: Taylor Woods ]
[ March 29, 2005: Message edited by: Taylor Woods ]
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taylor,
If u don't want to use the arguments in specifying ur input... You can just remove your if-condition check at the beginning of the program...

Instead of
String inputfile = args[0];
String outputfile = args[1];

Just use
String inputfile = textYouWant;
String outputfile = args[0];

But you still need to specify the output file when running your program... But you just need one arguments... Like the following...

java WordTree C:\MyOutputFile.txt

I hope this helps...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic