title: How to access mapped network drive from java application?
body: <p>I have a network drive mapped as:</p>
  
  <p>net use h: \ip\servername</p>
  
  <p>I have a normal java application that is going to read a txt file from that drive.</p>
  
  <p>Code:</p>
  
  <pre><code>File file = new File("H:\\MyFile.txt");
  
  try {
      byte[] bytes = Files.readAllBytes(Paths.get(file.getAbsolutePath()));
  } catch (IOException ex) {
      Logger.getLogger(JavaApplication25.class.getName()).log(Level.SEVERE, null, ex);
  }
  </code></pre>
  
  <p>When i run this program from my computer (windows 7 or from another computer with windows vista), the program runs without any problem.</p>
  
  <p>However, when i run this program from a computer with Windows 10, i get the following error:</p>
  
  <pre><code>java.nio.file.NoSuchFileException: H:\MyFile.txt
  </code></pre>
  
  <p>But if i run the application using the following code it works:</p>
  
  <pre><code>File file = new File("\\ip\servername\MyFile.txt");
  
  try {
      byte[] bytes = Files.readAllBytes(Paths.get(file.getAbsolutePath()));
  } catch (IOException ex) {
      Logger.getLogger(JavaApplication25.class.getName()).log(Level.SEVERE, null, ex);
  }
  </code></pre>
  
  <p>How can i use the mapped drive letter instead of using the full address?</p>