title: How to move file from d: drive to C: drive using java
body: <p>I'm trying to moves files from <code>D drive</code> to <code>C drive</code> using <code>Java code</code> (<strong><code>access denied is the error</code></strong>) but if transfered from d drive to e drive same code works</p>
  
  <p>I tried following code.</p>
  
  <pre><code>public static void transferFile(String name) {
          try {
              File a = new File("D:\\" + name);
              System.out.println(path);
              File b = new File("C:\\" + name);
              input = new FileInputStream(a);
              output = new FileOutputStream(b);
  
              byte[] buf = new byte[1024];
              int length;
              while ((length = input.read(buf)) &gt; 0) {
                  output.write(buf, 0, length);
              }
              input.close();
              output.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>