private static void deleteFile(File file) { try { if (file.exists()) { file.delete(); Log.info("File " + file.getName() + " is deleted."); } } catch (Exception e) { Log.info("Error deleting file " + file.getName() + ". Error:" + e.getMessage()); } }
public static synchronized void deleteIncompleteDownloads() { try { File directory = new File(Config.downloadPath); File[] files = directory.listFiles(); for (File file : files) { try { if (!file.delete()) Log.info("Cannnot delete temp file: " + file.getName()); } catch (Exception e) { Log.info("Cannnot delete temp file: " + file.getName() + ". Error:" + e.getMessage()); } } } catch (Exception e) { Log.error("Error in deleteIncompleteDownloads()", e.getCause() + ": " + e.getMessage()); } }