3 Replies Latest reply: Feb 27, 2007 2:18 PM by 807606 RSS

    Writing to a text file, then appending to it

    807606
      I need to write a heading in a text file and then append text after this e.g:

      heading
      -----------
      text1
      text2

      At the moment what i get is:

      heading
      -------------
      text1
      heading
      --------------
      text2
      public void displayProgress()
           {
                try 
                {
                     File outputFile = new File("Output.txt"); 
                  BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile, true));           
                     
                     bw.append("   " + (currentProcess + 1) + "\t"  + "\t" + "\t"  + status + "\t"  + "\t" + "\t"  + priority.get(currentProcess) + "\t"  + "\t" + "\t"  + time + "\t"  + "\t" + "\t"  + time + "\t"  + "\t");
                     bw.append("\n");
                     bw.flush();
                } 
                catch(IOException e)
                {
                     e.printStackTrace();
                }
           }
      Please suggest why this is happening.

      Cheers anyone