Java: BufferedWriter skipping newline
<p>I am using the following function to write a string to a File. The string is formatted with newline characters.</p>

<p>For example, <code>text = "sometext\nsomemoretext\nlastword";</code></p>

<p>I am able to see the newline characters of the output file when I do:</p>

<pre><code>type outputfile.txt
</code></pre>

<p>However, when I open the text in notepad I can't see the newlines. Everything shows up in a single line.</p>

<p>Why does this happen. How can I make sure that I write the text properly to be able to see correctly (formatted) in notepad.</p>

<pre><code>    private static void FlushText(String text, File file)
    {
        Writer writer = null;
        try
        {          
            writer = new BufferedWriter(new FileWriter(file));
            writer.write(text);
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        } 
        finally
        {
            try
            {
                if (writer != null)
                {
                    writer.close();
                }
            } 
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }
</code></pre>
