|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.senn.magic.io.Directory
public class Directory
This class represents a directory on a file system.
This class was created to make some typical directory-actions easier, since Java
enforces users to work with File
objects, which can be less straight forward than one
would hope!
Field Summary | |
---|---|
protected List<Directory> |
childDirectories
|
protected List<File> |
childFiles
|
protected File |
directoryFile
|
Constructor Summary | |
---|---|
protected |
Directory(File file)
Protected constructor, for internal use only. |
|
Directory(File file,
boolean getSubChildren)
|
|
Directory(String path,
boolean getSubChildren)
|
Method Summary | |
---|---|
int |
childrenCount()
Counts how many children are in the Directory . |
void |
copyTo(File file)
Copies a file to the current Directory |
boolean |
createChildDirectories(String names)
Create new nested child directories under the current Directory . |
boolean |
createChildDirectory(String name)
Create a new child directory under the current Directory . |
boolean |
delete()
Deletes the directory and all his children. |
int |
directoryCount()
Counts how many actual folders are in the Directory . |
int |
fileCount()
Counts how many actual files are in the Directory . |
List<Directory> |
getChildDirectories()
Gets all the child-directories. |
List<File> |
getChildDirectoriesAsFile()
Gets all the child-directories as File objects. |
List<File> |
getChildFiles()
Gets all the child-files. |
File |
getDirectoryFile()
Gets the File object that represents the directory |
String |
getName()
Gets the name of the Directory . |
protected void |
processChildren(boolean getSubChildren)
Protected method, for internal use only. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List<File> childFiles
protected List<Directory> childDirectories
protected File directoryFile
Constructor Detail |
---|
public Directory(String path, boolean getSubChildren) throws DirectoryException
path
- the path where the directory is locatedgetSubChildren
- true if you want to include all children of children
(of children of children of ...) in the result (tree-wise)
DirectoryException
public Directory(File file, boolean getSubChildren) throws DirectoryException
file
- a File
object that represents your directorygetSubChildren
- true if you want to include all children of children
(of children of children of ...) in the result (tree-wise)
DirectoryException
protected Directory(File file) throws DirectoryException
file
- a File object that represents a directory
DirectoryException
Method Detail |
---|
protected void processChildren(boolean getSubChildren) throws DirectoryException
getSubChildren
- include children or not
DirectoryException
public File getDirectoryFile()
File
object that represents the directory
File
- the directory as a File
objectpublic List<File> getChildFiles()
File
objects for which file.isFile() equals true.
List
- the list of child-files as File
objectspublic List<Directory> getChildDirectories()
Directory
objects for which their respective File
objects have
true
returned for file.isDirectory()
.Directory
object with @param getSubChildren = true
, all of
these Directory
objects will contain a List
with their children (who then again have a List
for their children, and so on...).
List
- the list of child-directories as Directory
objectspublic List<File> getChildDirectoriesAsFile()
File
objects.
List
- the list of child-directories as File
objectspublic boolean createChildDirectory(String name) throws DirectoryException
Directory
.new File().mkdir()
name
- the name of the new directory
boolean
- true
if it succeeded, false
if it didn't
DirectoryException
public boolean createChildDirectories(String names) throws DirectoryException
Directory
.new File().mkdirs()
names
- the name of the new directory
boolean
- true
if it succeeded, false
if it didn't
DirectoryException
public void copyTo(File file) throws DirectoryException
Directory
file
- the original file that you want to copy to the directory
DirectoryException
public int childrenCount()
Directory
.
int
- the children countFileUtils.childrenCount(File)
public int fileCount()
Directory
.
int
- the file countFileUtils.fileCount(File)
public int directoryCount()
Directory
.
int
- the directory countFileUtils.directoryCount(File)
public String getName()
Directory
.directory.getDirectoryFile().getName()
String
- the name of the Directory
getDirectoryFile()
public boolean delete()
boolean
- true
if everything was deleted successfully,
false
if something went wrongFileUtils.deleteDir(File)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |