public class Folder extends File
Modifier and Type | Class and Description |
---|---|
static interface |
Folder.FileFilter
Filter for files
|
static interface |
Folder.FolderFilter
Filter for folders
|
pathSeparator, pathSeparatorChar, separator, separatorChar
Constructor and Description |
---|
Folder(File file)
Construct.
|
Folder(Folder parent,
String child)
Constructor.
|
Folder(String pathname)
Constructor.
|
Folder(String parent,
String child)
Constructor.
|
Folder(URI uri)
Constructor.
|
Modifier and Type | Method and 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.
|
file, getExtension, getParentFolder, inputStream, lastModifiedTime, outputStream, readObject, readString, sync, toQuotedString, write, write, write, writeObject
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
public Folder(Folder parent, String child)
parent
- parentchild
- childpublic Folder(File file)
file
- Filepublic Folder(String pathname)
pathname
- path namepublic Folder(String parent, String child)
parent
- parentchild
- childpublic Folder(URI uri)
uri
- folder uripublic void ensureExists() throws IOException
IOException
- Thrown if folder cannot be createdpublic Folder folder(String name)
name
- Name of child folderpublic Bytes freeDiskSpace()
public File[] getFiles()
public File[] getNestedFiles()
public File[] getNestedFiles(Folder.FileFilter filter)
filter
- The filterpublic File[] getFiles(Folder.FileFilter filter)
filter
- File filterpublic Folder[] getFolders()
public Folder[] getFolders(Folder.FolderFilter filter)
filter
- Folder filterpublic boolean remove()
remove
in class File
File.delete()
public boolean removeFiles()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.