Hi Folks,
I am having difficult with a program. I have a program that downloads a file to the directory it is being run from and I need to move it to another one after its done downloading.
I found code that should do it but it keeps failing, and driving me up the wall.
import java.io.File;
public class main{
public static void main(String[] args){
// File (or directory) to be moved
File file = new File("test.txt");
// Destination directory
File dir = new File("C:\\Program Files\\WOOT_IT_WORKED.txt");
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
System.out.println("Move Failed");
}
}
}