List of utility methods to do File Path Delete
void | deleteIfExist(String filePath) Delete the file/directory if exist. File file = new File(filePath); if (file.exists()) { file.delete(); |
void | deleteInPathTempFiles(String workingFolder) delete In Path Temp Files String destFolder = workingFolder + "/OPS000"; for (Object[] xmlGraph : getProviderGraphs()) { String resourceFile = xmlGraph[0].toString(); new File(destFolder.concat(resourceFile)).delete(); new File(destFolder.concat(destFolder)).delete(); |
void | deleteInRemote(String host, String path) delete In Remote if (!runCommandInRemoteHost(host, "rm -rf " + path, 0).isEmpty()) throw new IOException("fail to delete " + path + " in " + host); |
void | deleteJaasFile(String jaasPath) delete Jaas File File jaasFile = new File(jaasPath); if (jaasFile.exists()) { if (!jaasFile.delete()) { throw new IOException("Failed to delete exists jaas file."); |
void | deleteKey(String path, String key) Deletes a registry key from the Windows registry. Objects.requireNonNull(path); List<String> command = new ArrayList<>(); command.add("reg"); command.add("delete"); command.add(path); if (key != null) { command.add("/v"); command.add(key); ... |
void | deleteMultipleFiles(String filePath, int numberOfFiles) delete Multiple Files for (int i = 0; i < numberOfFiles; i++) { deleteRecursively(new File(filePath + "." + (i + 1))); |
boolean | deleteNonEmptyDirectory(String dirPath) Deletes a non-empty directory, defined by dirPath from the file system. File dir = new File(dirPath); if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i]; boolean fileDeleted = file.delete(); if (!fileDeleted) return false; ... |
void | deleteOldStorageFile(String filepath) Delete the original storage file that the activity manager is saved in File oldStorage = new File(filepath);
oldStorage.delete();
|
void | deleteParent(String filePath) Delete source file and parent folder if empty File file = new File(filePath); if (file.exists()) { file.delete(); File parent = file.getParentFile(); while (parent.exists() && parent.isDirectory() && parent.listFiles().length == 0) { parent.delete(); parent = parent.getParentFile(); ... |
void | deletePath(File dirPath) Utilities for Files. recursiveDelete(dirPath); dirPath.delete(); |