Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8146538

File flush does not work

XMLWordPrintable

    • x86
    • windows_8

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10240]

      A DESCRIPTION OF THE PROBLEM :
      Using filestream.flush - data is not physically written to disc

      ADDITIONAL REGRESSION INFORMATION:
      I'd guess the problem is related to running on Windows 10 - is this platform not supported yet ?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      Build the code example in the "source code" box below.
      Check you have a c:\temp directory created.
      Run the code.
      Open a dos window, cd c:\temp and run the "dir" command a number of times
      Check the size of the file TestFile.log, it should slowly increase.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -

      I'd expect to see the file size gradually increasing, however it stays at zero until the program is interrupted and exits.
      ACTUAL -
      File size stays at zero, confirmed with "dir" command in dos window

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package any.old.package;

      import java.io.File;
      import java.io.FileWriter;
      import java.io.IOException;

      public class TestFileAccess {

      public static void main(String[] args) throws InterruptedException, IOException {

      File f = new File("C:\\TEMP\\TestFile.log");
      FileWriter out = new FileWriter (f);
      for (;;) {
      out.write("Hello, World");
      out.flush();
      Thread.sleep(10);
      }
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      close the file writer stream and reopen it with append mode.

            rpatil Ramanand Patil (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: