![]() |
[JAVA] Using a printwriter in an AVL tree
Yes this is homework, but this is not supposed to be the part that trips us up.
The goal is to print an AVL tree in order to a file. I chose to go with a printwriter because it deals with strings easilly. I can get the correct output to a regular System.out command , but I cannot translate that to a file. I know that the problem is that every time I call the getTreeInfo method recursivly I am creating a new instance of my file and print writers and it is just overwriting the same data, but I cant think of a way around this. Any help would be awesome. I dont want code , just any nudge in the right direction. ( I know this should be simple) Code:
|
Just create the writer before calling getTreeInfo and pass the writer to the method:
Code:
private void getTreeInfo( AvlNode t, Writer out) throws IOException |
What he said :thumbsup:
|
Yeah i ended up getting it. Just had to sleep on it, Thanks for the help though
|
All times are GMT -8. The time now is 08:55 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project