Why does BufferedWriter write method produce different results?
<p>I don't understand why these two implementations produce different results?</p>

<p>Method with expected results:</p>

<pre><code>    private void writeToFile(WorkoutLog log){
        try {
        BufferedWriter out = new BufferedWriter(new FileWriter("src/exercise/textfile2.txt", true));

        out.write(log.name.toString() + ", " + log.type + ", " + log.duration + ", " + log.caloriesburned + "\n");
        out.close();
    }catch (IOException e) {  
        System.out.println("error writing record to text file " + e );
    }
}
</code></pre>

<p><strong>data file result</strong></p>

<p>jim, 1, 123, 246</p>

<p>mike, 3, 12, 24</p>

<p>jim, 4, 50, 100</p>

<p>joni, 5, 40, 80</p>

<p>Method with unexpected result:</p>

<pre><code>    private void writeToFile2(WorkoutLog log){
    try {
        BufferedWriter out = new BufferedWriter(new FileWriter("src/exercise/textfile2.txt", true));

        out.write(log.name.toString());
        out.write(", ");
        out.write(log.type);
        out.write(",");
        out.write(log.duration);
        out.write(",");
        out.write(log.caloriesburned);
        out.write("\n");
        out.close();
    }catch (IOException e) {  
        System.out.println("error writing record to text file " + e );
    }
}
</code></pre>

<p><strong>data file result</strong></p>

<p>joe, , ,@</p>

<p>fred, ,{,ö</p>

<p>Why is breaking the out.write statements onto separate lines causing the output to produce odd results?  Each method is being passed an array reference with object that stores the result to write as string, short, short short data types.</p>
