title: Java FileOutputStream String Writing
body: <p>I’ve been having issues with a Java File. It's designed to write line after line in a test file as a log. Unfortunately it overwrites the same line every time I call it.</p>
  
  <p>If anyone can help I would be eternally grateful as this has been driving me up the wall!</p>
  
  <p>Code Below.</p>
  
  <pre><code>public abstract class Log {
  
      protected static String DefaultLogFileLocation = "c:\\LOG.txt";
  
      public static void ToFile(String pInputString) {
          FileOutputStream pOUTPUT;
          PrintStream pPRINT;
          try
          {
              pOUTPUT = new FileOutputStream(DefaultLogFileLocation);
              pPRINT = new PrintStream(pOUTPUT);
              pPRINT.println (pInputString + "\n");
              pPRINT.close();
          }
          catch (Exception e)
          {
              System.err.println ("Error writing to file");
          }
      }
  }
  </code></pre>