I want to copy file to another directory.I know this has been asked million times,I read tons of answers about this but I just can't seem to make it work.This is the code I am currently using:
copyFile(new File(getClass().getResource("/jars/TurnOffClient.jar").toString()),
new File("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\karioc.jar"));
And this is the method:
public static void copyFile(File sourceFile, File destFile) throws IOException {
if(!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
destination.transferFrom(source, 0, source.size());
}
finally {
if(source != null) {
source.close();
}
if(destination != null) {
destination.close();
}
}
}
This is my dir: Directories http://imageshack.com/a/img820/6418/5g3m.png
//////////////////////////////////////////////////////////////////////////////////////////
And this is the exception I get: