我正在尝试使用D drive
( C drive
)将文件从Java code
移动到access denied is the error
但是如果从d驱动器转移到e驱动相同的代码工作
我尝试了以下代码。
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();
}
}