• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need help outputting to a text file...

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

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic