title: java copy file on network drive
body: <p>I'm trying to copy files from a network drive to a folder, where I can access them online. A file looks like this, for example</p>
  
  <pre><code>\\GVSSQLVM\Lieferscheine\20011023\Volumed 5005.00000063.doc
  </code></pre>
  
  <p>which I can access in the Windows explorer, when I type this address in.</p>
  
  <p>And the destination to copy the file to would be</p>
  
  <pre><code>C:\Program Files\jbossAS\server\default\deploy\ROOT.war\tmp\Volumed 5005.doc
  </code></pre>
  
  <p>I run into trouble copying the file with following code:</p>
  
  <pre><code>        String doc_dir = "\\\\GVSSQLVM\\Lieferscheine\\20011023\\";
          String doc_file = doc_dir.concat(doc.getUniqueFileName());
          File source = new File(doc_file);
  
          String home_url = System.getProperty("jboss.server.home.url");
          String home_dir = home_url.substring(5); // cut out preceding file:/
          String tmp_dir = home_dir.concat("deploy/ROOT.war/tmp/");
          String dest_file = tmp_dir.concat(title);
          File dest = new File(dest_file);
  
          try {
                  input = new FileInputStream(source);
                  output = new FileOutputStream(dest);
                  byte[] buf = new byte[1024];
                  int bytesRead;
                  while ((bytesRead = input.read(buf)) &gt; 0) {
                      output.write(buf, 0, bytesRead);
                  }
          } finally {
              input.close();
              output.close();
          }
  </code></pre>
  
  <p>input is <code>null</code>. I read that the space character could be troublesome, and followed the advice to put the <code>source</code> for the <code>FileInputStream</code> in quotes, but then <code>new File</code> seems to screw the whole filename up into</p>
  
  <pre><code>c:\Program Files\jbossAS\bin\'\GVSSQLVM\Lieferscheine\20011023\Volumed 5005.00000063.doc'
  </code></pre>
  
  <p>where it seems to write the current path first, then add the given one with one backslash less; and it still doesn't find the file. 
  <code>file.extists()</code> yields false.</p>
  
  <p>Thank you for your help!</p>