Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help outputting to a text file...

 
Adam Ellsworth
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, don't use that code, the output is hard to follow. This is a little better...

 
Jimmy Die
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
Adam Ellsworth
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic