I have three directories A, B & C on windows. I have a file that exists in directory A. I want to do the following tasks
- Copy it to directory B
- Delete it from directory A (This WORKED since the file was not being held by any process)
- Copy it to directory C
- Delete it from directory B (NOT Work)
Steps 1,2,3 work fine but it does not work with step 4. The file exists and can write, read, execute. When I open windows explorer and try to delete the file in directory B manually, it said the action can't be completed because it's opened in java platform SE binary. Below is my code for copying the file
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
I'm using Java 6. Do you know how I can accomplish step 4?