Here you can find the source of canDownload(String filePath)
public static boolean canDownload(String filePath)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class Main { public static boolean canDownload(String filePath) { try {/*from w w w . jav a 2 s. com*/ // Cause an exception if the program is already running if (new File(filePath).exists()) { Files.delete(Paths.get(filePath)); } return true; } catch (IOException ignored) { return false; } } }