aspose file tools*
The moose likes Java in General and the fly likes Need help outputting to a text file... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help outputting to a text file..." Watch "Need help outputting to a text file..." New topic
Author

Need help outputting to a text file...

Adam Ellsworth
Greenhorn

Joined: Sep 25, 2004
Posts: 21
I have a binary search tree and need to output it before it clears to create the next one. I can output strings in the main but can't figure out how to put anything dealing with the tree to the outputted text file. Here's my code, please help, hehe. Thanks

Code:

Adam Ellsworth
Greenhorn

Joined: Sep 25, 2004
Posts: 21
Sorry, don't use that code, the output is hard to follow. This is a little better...

Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
Hi,



I'm a little unclear about some of the specifics of your data, and what sort of fuctionality's your accomplishing, however I created a file "Latin.txt" with the following entries:

%casa:home
%uno ne
%dose:two

Then with this method below I create similiar output to what you have in "Latin.txt". The current positioning of your output to the console will not be the same as your output written to file "Output.txt" until you adjust the logic. There are other ways of accomplishing writing to files, such as using channels. Anyhow this is one way of accomplishing this, but I would personally utilize the channels from java.nio ... I'm sure there are tutuorials out there to review...

P.S. I was never prompted for input from your variable 'stdin' (no stdin.readLine()) which leads me to believe that your program is still being refined...

Good luck!



Jimmy Die
Adam Ellsworth
Greenhorn

Joined: Sep 25, 2004
Posts: 21
Thanks for your help Jimmy Your suggestion unfortunately didn't work either. Sorry for the very vague question and sloppy code. I was in a hurry and didn't have too much time to do anything I ended up appending the text file and it kind of worked. It would output to the console perfectly, but the output to the text file was all screwy, but at least it outputted something The program was turned in today and I can post the results on how to make it work if anyone cares to see, hehe. Thanks again, Adam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help outputting to a text file...
 
Similar Threads
cannot be applied to
Binary Tree's
Help with expression Tree
Binary search tree questions...
how to set a node on expression tree