How do I edit the end of a text File in java Across multiple instances of a class
<p>I am writing code which stores Exceptions and comments about exceptions in a text file.
And I am running into an issue where every time I call a new instance of my StoreErrors Class the Error file is rewritten instead of writing data to the end of the file.</p>

<pre><code>public StoreErrors(Exception e){
        //increment the error number as the number of times StoreErrors
        //was intialized
       errorNum +=1;
       try{
           FileOutputStream toWriter;
           if(!errReport.exists()){
               boolean isCreated =errReport.createNewFile();
               if(isCreated){
                   System.out.println("No Error Report was found a new one "
                           + "has been created");
               }
               /*if the file is already present set append to file to true on
                * FileOutputStream
                */
               toWriter=new FileOutputStream(errReport, true);
           }else{
               toWriter=new FileOutputStream(errReport);
           }
               //OutputStreamWriter allows toLog to be writen in UTF8
               //BufferedWriter Takes characters from the OutputStreamWriter
               /*Which Writes to the file using the File errReport using
               * FileOutputStream toWriter
               */
               toLog=new BufferedWriter(new OutputStreamWriter(
                   toWriter, "UTF8"));
           /*Creates and exception object which can be used to get information
            * about the error that occured
           */
           storeException=e;
       }catch (UnsupportedEncodingException encEx){
           encEx.printStackTrace();
       }catch(IOException ioEx){
           ioEx.printStackTrace();
       }catch (Exception ex){
           ex.printStackTrace();
       }
    }
</code></pre>

<p>This is the constructor that is called each time a new error is stored.
Please let me know if using the combination of BufferedReader(OutputStreamWriter(FileOutputStream(File, append boolean), Encoding))  is correct. 
Both errorNum and  errReport are static. The file declarations is below:</p>

<p>private static File errReport=new File("err_Report.txt");</p>

<p>Also I used toLog.write("string"+"\r\n") instead of append when actually using the writer to write to the file.
Question being how do I make it so that way every time I call the class it appends the end of the same file, and why is it overwriting the file with the current code?</p>
