I\'m downloading an ePub file from a URL.
Now I want to implement a mechanism by which if user tries to re-download the same file, he should get warning/error messag
You dont really have to compare file names. Just make File object for the file with absolute path and check if file exists.
protected boolean need2Download(String fileName) {
File basePath = new File(BOOK_STORE_PATH);
File fullPath = new File(basePath, fileName);
if (fullPath.exists())
return false;
return true;
}
protected void downloadFile(String url) {
String fileName = url.substring(url.lastIndexOf('/') + 1);
if (need2Download(fileName)) {
// download
}
}