de.goerntkai.toolbox.fs
Class Folder

java.lang.Object
  extended byjava.io.File
      extended byde.goerntkai.toolbox.fs.File
          extended byde.goerntkai.toolbox.fs.Folder
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Folder
extends File

Represents a folder object in the file system. The base de.goerntkai.devbase.tools.File is extended with hasSubdirectories, deleteContents and deleteWithContents. The copyTo which copies the folder to the given destination is overwritten.

Version:
$Id: Folder.java,v 1.4 2007/05/06 16:25:51 GoerntKai Exp $
Author:
Kai Görnt
See Also:
File, Serialized Form

Field Summary
 
Fields inherited from class de.goerntkai.toolbox.fs.File
SUFFIX_SEPERATOR
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
Folder(java.io.File theFile)
          Creates a new Folder from an object of its superclass.
Folder(File theParent, java.lang.String theChild)
          Inherited from de.goerntkai.devbase.tools.File.
Folder(java.lang.String thePathname)
          Inherited from de.goerntkai.devbase.tools.File.
Folder(java.lang.String theParent, java.lang.String theChild)
          Inherited from de.goerntkai.devbase.tools.File.
Folder(java.net.URI theURI)
          Inherited from de.goerntkai.devbase.tools.File.
 
Method Summary
 long copyTo(java.io.File destination)
          Copies this folder object to the given destination folder.
 long copyTo(Folder destination)
          Copies this folder object to the given destination file.
 boolean deleteContents()
          Deletes the folder and recursively all its subdirectories.
 boolean deleteWithContents()
          Deletes recursively all the subdirectories, the contending files and at last the folder itself.
 boolean hasSubdirectories()
          Returns true when there is at least one subdirectory or false if there is none.
 java.io.File[] listFiles()
          Inherited from java.io.File.
 
Methods inherited from class de.goerntkai.toolbox.fs.File
copyTo, copyTo, getBareName, getSuffix
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Folder

public Folder(File theParent,
              java.lang.String theChild)

Inherited from de.goerntkai.devbase.tools.File.

Parameters:
theParent - to create the child in
theChild - to create
See Also:
File

Folder

public Folder(java.io.File theFile)
       throws NoFolderException

Creates a new Folder from an object of its superclass.

Parameters:
theFile - to create
Throws:
NoFolderException - when myself is no directory

Folder

public Folder(java.lang.String thePathname)
       throws NoFolderException

Inherited from de.goerntkai.devbase.tools.File.

Parameters:
thePathname - of the file
Throws:
NoFolderException - when pathname is no directory
See Also:
File

Folder

public Folder(java.lang.String theParent,
              java.lang.String theChild)

Inherited from de.goerntkai.devbase.tools.File.

Parameters:
theParent - to create the child in
theChild - to create
See Also:
File

Folder

public Folder(java.net.URI theURI)

Inherited from de.goerntkai.devbase.tools.File.

Parameters:
theURI - of the file
See Also:
File
Method Detail

copyTo

public final long copyTo(Folder destination)
                  throws java.io.IOException

Copies this folder object to the given destination file. Copies files as well as directories recursively. Returns the number of bytes that were copied. Returns -1 if the source was no folder or does not exist.

Parameters:
destination - where to copy the folder to
Returns:
the number of bytes that were copied
Throws:
java.io.IOException - on problems with the streams
See Also:
File.copyTo(java.lang.String), copyTo(Folder)

copyTo

public final long copyTo(java.io.File destination)
                  throws java.io.IOException

Copies this folder object to the given destination folder. Just calls copyTo(Folder) with the Folder created from destination.

Parameters:
destination - where to copy the folder to
Returns:
the number of bytes that were copied
Throws:
java.io.IOException - on problems with the streams
See Also:
File.copyTo(java.lang.String), copyTo(Folder)

deleteContents

public final boolean deleteContents()

Deletes the folder and recursively all its subdirectories. Returns false if the folder is no directory.

Returns:
wether the operation was successful

deleteWithContents

public final boolean deleteWithContents()

Deletes recursively all the subdirectories, the contending files and at last the folder itself.

Returns:
wether the operation was successful

hasSubdirectories

public final boolean hasSubdirectories()

Returns true when there is at least one subdirectory or false if there is none. If the folder is no directory it will return false as well.

Returns:
wether there is a subdirectory

listFiles

public final java.io.File[] listFiles()

Inherited from java.io.File. Returns an array of java.io.File but the results may be casted to de.goerntkai.toolbox.misc.File or de.goerntkai.toolbox.misc.Foler.

Returns:
an array of castable java.io.File
See Also:
File.listFiles()


Copyright © 2004-2007 Kai Görnt. All Rights Reserved.