private void move(File f, File dest) {
try {
loading = "Moving: " + f.getName();
File tmp = new File(dest.getPath() + System.getProperty("file.separator") + f.getName());
RandomAccessFile out = new RandomAccessFile(tmp, "rw");
RandomAccessFile in = new RandomAccessFile(f, "rw");
byte[] buf = new byte[8182];
int read = 0;
while (true) {
read = in.read(buf);
if (read == -1) {
break;
}
out.write(buf, 0, read);
}
out.close();
in.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
} |