Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because you are not explicitly locking the entire file before the copy action the default os file locking mechanism is at work. </p> <p>I ran a quick test program to see what happens on a Windows machine when you copy a source file while an external process is writing to the file every 2secs. </p> <p>The process that writes to the file never encountered a problem. </p> <pre><code>public static void main(String[] args) { File f = new File("..\\test.txt"); long startTime = System.currentTimeMillis(); long elapsedTime = 0; while (elapsedTime &lt; 1000 * 60) { try { FileUtils.writeStringToFile(f, System.currentTimeMillis()+" : Data Write\r\n", true); Thread.sleep(2000); } catch (IOException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex){ Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } elapsedTime = System.currentTimeMillis() - startTime; } } </code></pre> <p>The process that copies the file will throw an exception if it does not finish the copy before the source file changes length. It appears that this exception is more of a warning that the copied version of the file is incomplete. When I synced timing to keep from reading from the file at the same time writing happens this exception was not thrown.</p> <pre><code>public static void main(String[] args) { File f = new File("..\\test.txt"); long startTime = System.currentTimeMillis(); long elapsedTime = 0; while (elapsedTime &lt; 1000 * 60) { try { FileUtils.copyFile(f, new File("..\\test\\test.txt")); Thread.sleep(2000); } catch (IOException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex){ Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } elapsedTime = System.currentTimeMillis() - startTime; } } </code></pre> <p>Based on this test I would not worry about what happens to the writing process. I would do something to handle the case when <code>java.io.IOException: Failed to copy full contents from '..\test.txt' to '..\test\test.txt'</code> is thrown.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload