Writing data from different classes to a text file using BufferedWriter
<p>I am working with Java.</p>

<p>I have created one text file. In that text file, I want one value to be stored in the text file from class1.  Then I want one more value to be stored in the textfile from class2 on the 2nd line. Then I want one more value to be stored in line 3 of the text file from class 3 , etc. The text file, when retrieved, should look like this:</p>

<pre><code>77 
65 
34
</code></pre>

<p>The problem I encounter is that, the text file content gets erased when I move on to the next class. For example, the text file would only show the last data value. And erase the previous ones (in the example above, only 34 would appear that too on the first line, when it should be on the 3rd line). </p>

<p>Some code from class1:</p>

<pre><code>BufferedWriter outputFile0=null;
    try {
        int x = value_MAP();        
        FileWriter fwriter0 =new FileWriter("MAP_allData.txt");
            outputFile0 = new BufferedWriter(fwriter0);
                outputFile0.write(""+x);
                outputFile0.newLine();  
                               } catch( Exception y ) {y.printStackTrace();}
</code></pre>

<p>Same code again appears in class2, class3, etc:</p>

<pre><code>BufferedWriter outputFile0=null;
        try {
            int x = value_MAP();        
            FileWriter fwriter0 =new FileWriter("MAP_allData.txt");
                outputFile0 = new BufferedWriter(fwriter0);
                    outputFile0.write(""+x);
                    outputFile0.newLine();  
                                   } catch( Exception y ) {y.printStackTrace();}
</code></pre>

<p>So is there a way to tell Java that dont worry about erasing the data, just add data one line after another when traveling from class 1 to class x. </p>
