I am working on Android. My requirement is that I have one directory with some files, later I downloaded some other files into another directory and my intention is to copy all the files from latest directory into first directory. And before copying the files into first directory from latest I need to remove all files from the first directory.
void copyFile(File src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
}
I can't remember where I found this, but it was from a useful article I used to backup a SQLite database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With