I have a method for copying files:
private static void copy(final String source, final String destination) {
try {
final File f1 = new File(source);
final File f2 = new File(destination);
final InputStream in = new FileInputStream(f1);
final OutputStream out = new FileOutputStream(f2);
final byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (final FileNotFoundException ignored) {
} catch (final IOException ignored) {}
}
Is there a way I can override the “Access is denied” error when copying to a directory?
NOTE: I only need this for Windows computers.
No. If you’re on UNIX, running the program as a user with write privileges for the directory will be required. Just curious, why would you want to override filesystem permissions? Why not just use the appropriate permissions?