writing results of recursion into file

hello
I have recursive function and I want to write the results of this recursive function into file without deleting the old content of file but the problem I have is that when I call recursive function it overwrites results on the content of file
this is the code

hello
I have recursive function and I want to write the results of this recursive function into file without deleting the old content of file but the problem I have is that when I call recursive function it overwrites results on the content of file
this is the code

Don't (re)open the output file every time your recursive method runs but pass it an OutputStream as a parameter. Close the stream outside of that method when it has finished (and open it before you call it for the first time).