Package org.apache.wicket.util.file
Class Folder
- java.lang.Object
-
- java.io.File
-
- org.apache.wicket.util.file.File
-
- org.apache.wicket.util.file.Folder
-
- All Implemented Interfaces:
Serializable
,Comparable<File>
,IModifiable
public class Folder extends File
This folder subclass provides some type safety and extensibility for "files" that hold other files.- Author:
- Jonathan Locke
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Folder.FileFilter
Filter for filesstatic interface
Folder.FolderFilter
Filter for folders
-
Field Summary
-
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
ensureExists()
Does a mkdirs() on this folder if it does not exist.Folder
folder(String name)
Bytes
freeDiskSpace()
File[]
getFiles()
File[]
getFiles(Folder.FileFilter filter)
Folder[]
getFolders()
Gets all folders in this folder, except "." and ".."Folder[]
getFolders(Folder.FolderFilter filter)
File[]
getNestedFiles()
File[]
getNestedFiles(Folder.FileFilter filter)
Gets files in this folder matching a given filter recursively.boolean
remove()
Removes this folder and everything in it, recursively.boolean
removeFiles()
Removes all the files in this folder.-
Methods inherited from class org.apache.wicket.util.file.File
file, getExtension, getParentFolder, inputStream, lastModifiedTime, outputStream, readObject, readString, sync, toQuotedString, write, write, write, writeObject
-
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
-
-
-
-
Method Detail
-
ensureExists
public void ensureExists() throws IOException
Does a mkdirs() on this folder if it does not exist. If the folder cannot be created, an IOException is thrown.- Throws:
IOException
- Thrown if folder cannot be created
-
folder
public Folder folder(String name)
- Parameters:
name
- Name of child folder- Returns:
- Child file object
-
freeDiskSpace
public Bytes freeDiskSpace()
- Returns:
- Disk space free on the partition where this folder lives
-
getNestedFiles
public File[] getNestedFiles()
- Returns:
- All files nested within this folder
-
getNestedFiles
public File[] getNestedFiles(Folder.FileFilter filter)
Gets files in this folder matching a given filter recursively.- Parameters:
filter
- The filter- Returns:
- The list of files
-
getFiles
public File[] getFiles(Folder.FileFilter filter)
- Parameters:
filter
- File filter- Returns:
- Files
-
getFolders
public Folder[] getFolders()
Gets all folders in this folder, except "." and ".."- Returns:
- Folders
-
getFolders
public Folder[] getFolders(Folder.FolderFilter filter)
- Parameters:
filter
- Folder filter- Returns:
- Folders
-
remove
public boolean remove()
Removes this folder and everything in it, recursively. A best effort is made to remove nested folders and files in depth-first order.- Overrides:
remove
in classFile
- Returns:
- True if the folder was successfully removed
- See Also:
File.delete()
-
removeFiles
public boolean removeFiles()
Removes all the files in this folder.- Returns:
- True if any files were successfully removed
-
-