Class FileSystemUtils
java.lang.Object
org.springframework.util.FileSystemUtils
Utility methods for working with the file system.
- Since:
- 2.5.3
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcopyRecursively(File src, File dest) Recursively copy the contents of thesrcfile/directory to thedestfile/directory.static voidcopyRecursively(Path src, Path dest) Recursively copy the contents of thesrcfile/directory to thedestfile/directory.static booleandeleteRecursively(@Nullable File root) Delete the suppliedFile- for directories, recursively delete any nested directories or files as well.static booleandeleteRecursively(@Nullable Path root) Delete the suppliedPath— for directories, recursively delete any nested directories or files as well.
- 
Constructor Details- 
FileSystemUtilspublic FileSystemUtils()
 
- 
- 
Method Details- 
deleteRecursivelyDelete the suppliedFile- for directories, recursively delete any nested directories or files as well.Note: Like File.delete(), this method does not throw any exception but rather silently returnsfalsein case of I/O errors. Consider usingdeleteRecursively(Path)for NIO-style handling of I/O errors, clearly differentiating between non-existence and failure to delete an existing file.- Parameters:
- root- the root- Fileto delete
- Returns:
- trueif the- Filewas successfully deleted, otherwise- false
 
- 
deleteRecursively@Contract("null -> false") public static boolean deleteRecursively(@Nullable Path root) throws IOException Delete the suppliedPath— for directories, recursively delete any nested directories or files as well.- Parameters:
- root- the root- Pathto delete
- Returns:
- trueif the- Pathexisted and was deleted, or- falseif it did not exist
- Throws:
- IOException- in the case of I/O errors
- Since:
- 5.0
 
- 
copyRecursivelyRecursively copy the contents of thesrcfile/directory to thedestfile/directory.- Parameters:
- src- the source directory
- dest- the destination directory
- Throws:
- IOException- in the case of I/O errors
 
- 
copyRecursivelyRecursively copy the contents of thesrcfile/directory to thedestfile/directory.- Parameters:
- src- the source directory
- dest- the destination directory
- Throws:
- IOException- in the case of I/O errors
- Since:
- 5.0
 
 
-