Class FileUtilitiesKt
-
- All Implemented Interfaces:
public final class FileUtilitiesKt
-
-
Method Summary
Modifier and Type Method Description final static BooleandeleteQuietly(File $self)Try and delete this file or directory quietly. final static Doublesize(File $self)Acquire the size of this file or directory in bytes. final static List<File>regexWalk(File $self, List<Regex> filters, FileWalkDirection direction)Walk this directory and return all file-objects which match any of the regular expressions in the provided list. final static List<File>filteredWalk(File $self, List<String> filters, FilterType filterType, FileWalkDirection direction, Boolean recursive)Walk this directory and return all file-objects which match the specified filter-type using the passed list of filters. final static Unitcreate(File $self, Boolean createFileOrDir, Boolean asDirectory)All parent directories are created, but not the file itself. final static BooleantestFileWrite(File $self)Test whether files can be written to this file denoting a directory. -
-
Method Detail
-
deleteQuietly
final static Boolean deleteQuietly(File $self)
Try and delete this file or directory quietly. Deleting something quietly means that
No guarantee is made whether the file or directory is successfully deleted
No exceptions are thrown if an error occurs
No information is carried outside should an exception occur, meaning you have no information about why the deletion, if it failed
- Returns:
trueif, and only if, the file or directory was deleted.
-
size
final static Double size(File $self)
Acquire the size of this file or directory in bytes. If this file-object denotes a directory, then the size of all files in the directory will be checked and the sum of them returned.
- Returns:
The filesize of this file, or sum of sizes of all files in this directory.
-
regexWalk
final static List<File> regexWalk(File $self, List<Regex> filters, FileWalkDirection direction)
Walk this directory and return all file-objects which match any of the regular expressions in the provided list.
- Parameters:
filters- List of regular expressions to use for filtering.direction- The direction in which to walk the directory.- Returns:
All files inside this directory which matched the given filters.
-
filteredWalk
final static List<File> filteredWalk(File $self, List<String> filters, FilterType filterType, FileWalkDirection direction, Boolean recursive)
Walk this directory and return all file-objects which match the specified filter-type using the passed list of filters.
- Parameters:
filters- List of Strings to use for filteringfilterType- Whether to filter by FilterType.CONTAINS (default), FilterType.ENDS_WITH or FilterType.STARTS_WITH.direction- The direction in which to walk the directory.- Returns:
All files inside this directory which matched the given filters.
-
create
final static Unit create(File $self, Boolean createFileOrDir, Boolean asDirectory)
All parent directories are created, but not the file itself.
createFileOrDir in combination with asDirectory will result in this file being treated as a directory. As such, all parents will be created, along with this file itself being created as a directory.
createFileOrDir without asDirectory will result in this file being created as a file.
- Parameters:
createFileOrDir- Whether the file or directory should be created.asDirectory- true to create a directory, false to create a file.
-
testFileWrite
final static Boolean testFileWrite(File $self)
Test whether files can be written to this file denoting a directory. If this file is not a directory, an IllegalArgumentException will be thrown.
-
-
-
-