I'm trying to moves files from D drive
to C drive
using Java code
(access denied is the error
) but if transfered from d drive to e drive same code works
I tried following 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)) > 0) {
output.write(buf, 0, length);
}
input.close();
output.close();
} catch (Exception e) {
e.printStackTrace();
}
}