Keel 2.1RC2

org.keel.apps.fileservices
Class DefaultFile

java.lang.Object
  extended byorg.keel.apps.fileservices.DefaultFile
All Implemented Interfaces:
File

public class DefaultFile
extends java.lang.Object
implements File

Provides a wrapper for the java.io.File object, to allow for usage by the File Models.

Author:
Stephen Davidson

Field Summary
static int BUFFER_SIZE
          The Default buffer size for file transfers, in bytes Currently, the default is 1MB.
protected  java.io.File file
           
 
Constructor Summary
DefaultFile(java.io.File file)
           
DefaultFile(java.lang.String fileName)
          Constructor for DefaultFile.java
DefaultFile(java.lang.String dir, java.lang.String fileName)
          Constructor for DefaultFile.java
 
Method Summary
 void copyTo(File dest)
          Copies a file from one File Object to another.
 void delete(boolean deleteChildren)
          Deletes the file associated with this File Object.
 java.lang.String getFileName()
          Gets the local file name of the current file object
 java.lang.String getFilePath()
          Get the full path of the current file object
 java.io.FileOutputStream getOutputStream()
          Get the writeable OutputStream for the underlying file object.
 void mkdir(boolean makeParents)
          Make the directory specified by the given path name
 void moveTo(File dest)
          Moves a file from one location to the specified destination
 void moveTo(java.lang.String dest)
          Moves a file from one location to the specified destination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
The Default buffer size for file transfers, in bytes Currently, the default is 1MB.

See Also:
Constant Field Values

file

protected final java.io.File file
Constructor Detail

DefaultFile

public DefaultFile(java.lang.String fileName)
Constructor for DefaultFile.java


DefaultFile

public DefaultFile(java.lang.String dir,
                   java.lang.String fileName)
Constructor for DefaultFile.java

Parameters:
dir -
fileName -

DefaultFile

public DefaultFile(java.io.File file)
Method Detail

copyTo

public void copyTo(File dest)
            throws java.io.IOException
Copies a file from one File Object to another. The preferred implementation is to grab the underlying Channel, and use Channel Reads/Writes by buffer.

Specified by:
copyTo in interface File
Parameters:
dest - The Destination to copy to.
Throws:
java.io.IOException - Thrown if an error occurs during copy operation
See Also:
File.copyTo(org.keel.apps.fileservices.File)

moveTo

public void moveTo(java.lang.String dest)
            throws java.io.IOException
Moves a file from one location to the specified destination

Specified by:
moveTo in interface File
Parameters:
dest - The filename to move this file to
Throws:
java.io.IOException - Thrown if the file system errors out during the move
See Also:
File.moveTo(java.lang.String)

moveTo

public void moveTo(File dest)
            throws java.io.IOException
Moves a file from one location to the specified destination

Specified by:
moveTo in interface File
Parameters:
dest - The destination to move this file to. Used especially for propietary and networked filesystems.
Throws:
java.io.IOException - Thrown if the file system errors out during the move
See Also:
File.moveTo(org.keel.apps.fileservices.File)

delete

public void delete(boolean deleteChildren)
            throws java.io.IOException
Deletes the file associated with this File Object.

Specified by:
delete in interface File
Throws:
java.io.IOException - Thrown if the Delete fails for any reason.
See Also:
org.keel.apps.fileservices.File#delete()

mkdir

public void mkdir(boolean makeParents)
           throws java.io.IOException
Make the directory specified by the given path name

Specified by:
mkdir in interface File
Parameters:
makeParents - Make any required parent directories as well
Throws:
java.io.IOException - Thrown if an error occurs during the creation of the specified directory, or any parent directories.
See Also:
File.mkdir(boolean)

getOutputStream

public java.io.FileOutputStream getOutputStream()
                                         throws java.io.IOException
Get the writeable OutputStream for the underlying file object. Used for Reading/Writing, and obtaining the underlying Channel Object for fast Reading/Writing/Copying.

Specified by:
getOutputStream in interface File
Returns:
OutputStream for this File Object.
Throws:
java.io.IOException - Thrown if an error occurs opening OutputStream
See Also:
org.keel.apps.fileservices.File#getChannel()

getFileName

public java.lang.String getFileName()
Gets the local file name of the current file object

Specified by:
getFileName in interface File
Returns:
The local file name of the current file
See Also:
File.getFileName()

getFilePath

public java.lang.String getFilePath()
Get the full path of the current file object

Specified by:
getFilePath in interface File
Returns:
The full path name of the current file

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.