/** * Move a file or a folder to the global trash, depending on staticConfig. * * @param staticConfig * @param fileOrFolder * @return <code>true</code> if origin doesn't exist; or the result of {@link * File#renameTo(File)}. */ public static boolean moveToGlobalTrash(StaticConfig staticConfig, String fileOrFolder) { File file = new File(fileOrFolder); if (file.exists()) { String trashFolder = staticConfig.getTrashFolder(); File dest; int i = 1; String version = ""; do { dest = new File(trashFolder + '/' + file.getName() + version); version = "." + i; i++; } while (dest.exists()); dest.getParentFile().mkdirs(); return file.renameTo(dest); } return true; }