title: Does the following java code guarantee and exclusive lock on an unopened file in Windows?
body: <p>Does the following Java code guarantee an exclusive lock on an unopened file in Windows?</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  
  public class Test {
      public static void main(String[] args) {
          File file = new File("mylog.log");
          try {
              FileOutputStream fos = new FileOutputStream(file);
              fos.getChannel().lock();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>