title: How to prevent someone from deleting files that my program is currently using?
body: <p>I have a program that temporarily saves some Objects to my Hard-Disk only to be re-loaded a few minutes after:</p>
  
  <p>This is the method:</p>
  
  <pre><code>private void save(Object myObject, String path) throws IOException {
          final BufferedOutputStream bf = new BufferedOutputStream(
                  new FileOutputStream(path));
  
          final ObjectOutputStream objOut = new ObjectOutputStream(bf);
  
          objOut.writeUnshared(myObject);
  
          bf.close();
          bf.flush();
          objOut.flush();
          objOut.reset();
      }
  </code></pre>
  
  <p>The problem is that I'm able to delete the file from the disk at runtime, and ending up in a NoSuchFileException later:
  How to prevent this from happening?</p>
  
  <p>I also tried using</p>
  
  <pre><code>objOut.writeObject(myObject);
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>objOut.writeUnshared(myObject);
  </code></pre>
  
  <p>but still nothing...</p>
  
  <p>Can someone help me? Thanks!</p>
  
  <p><strong>EDIT</strong> Read comments for a more detailed description of the request!</p>