|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.cargo.util.DefaultFileHandler
public class DefaultFileHandler
File operations that are performed in Cargo. All file operations must use this class.
Constructor Summary | |
---|---|
DefaultFileHandler()
Initializations. |
Method Summary | |
---|---|
String |
append(String path,
String suffixToAppend)
Append a suffix path to an existing path. |
void |
copy(InputStream in,
OutputStream out)
Copies data from an InputStream to an OutputStream using a default buffer size. |
void |
copy(InputStream in,
OutputStream out,
int bufSize)
Copies data from an InputStream to an OutputStream. |
void |
copyDirectory(String source,
String target)
Copy a directory from a source to a destination. |
void |
copyDirectory(String source,
String target,
List excludes)
Copy a directory from a source to a destination specifying files to be excluded. |
void |
copyFile(String source,
String target)
Copy a file from a source to a destination specifying if source files may overwrite newer destination files. |
void |
copyFile(String source,
String target,
boolean overwrite)
Copy a file from a source to a destination specifying if source files may overwrite newer destination files. |
void |
copyFile(String source,
String target,
org.apache.tools.ant.types.FilterChain filterChain)
Copy a file from a source to a destination using a filterchain to specify token replacement. |
String |
createDirectory(String parentDir,
String name)
Convenience method for creating a new directory inside another one. |
void |
createFile(String file)
Create a file. |
String |
createUniqueTmpDirectory()
Creates a unique temporary directory. |
void |
delete(String path)
Deletes a file or directory, removing any children as appropriate. |
boolean |
exists(String path)
|
String |
getAbsolutePath(String path)
gets the absolute path from a file that may be relative to the current directory. |
String[] |
getChildren(String directory)
|
InputStream |
getInputStream(String file)
|
String |
getName(String file)
|
OutputStream |
getOutputStream(String file)
|
String |
getParent(String path)
|
String |
getTmpPath(String name)
Compute the location of a temporary directory. |
String |
getURL(String path)
|
boolean |
isDirectory(String path)
|
boolean |
isDirectoryEmpty(String dir)
|
void |
mkdirs(String path)
Create directories for the passed path. |
String |
readTextFile(String file)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultFileHandler()
Method Detail |
---|
public void copyFile(String source, String target)
copyFile
in interface FileHandler
source
- the file to copy from. Must not be null
.target
- the file to copy to. Must not be null
.FileHandler.copyFile(String, String)
public void copyFile(String source, String target, boolean overwrite)
copyFile
in interface FileHandler
source
- the file to copy from. Must not be null
.target
- the file to copy to. Must not be null
.overwrite
- to overwrite the file if it already exists.FileHandler.copyFile(String, String)
public void copyFile(String source, String target, org.apache.tools.ant.types.FilterChain filterChain)
copyFile
in interface FileHandler
source
- the file to copy from. Must not be null
target
- the file to copy to. Must not be null
filterChain
- the filterChain to use. Must not be null
FileHander#copyFile(String, String, FilterChain)
public void copyDirectory(String source, String target)
copyDirectory
in interface FileHandler
source
- the directory to copy from. Must not be null
.target
- the directory to copy to. Must not be null
.FileHandler.copyDirectory(String, String)
public void copyDirectory(String source, String target, List excludes)
copyDirectory
in interface FileHandler
source
- the directory to copy from. Must not be null
.target
- the directory to copy to. Must not be null
.excludes
- the list of files to be excluded. Each entry in the list is an
Ant file pattern.FileHandler.copyDirectory(String, String)
public String createDirectory(String parentDir, String name)
createDirectory
in interface FileHandler
parentDir
- The directory in which the new directory should be createdname
- The name of the directory to create
FileHandler.createDirectory(String, String)
public void copy(InputStream in, OutputStream out, int bufSize)
copy
in interface FileHandler
in
- InputStream to copy data fromout
- OutputStream to copy data tobufSize
- size of the copy bufferFileHandler.copy(java.io.InputStream, java.io.OutputStream, int)
public void copy(InputStream in, OutputStream out)
copy
in interface FileHandler
in
- InputStream to copy data fromout
- OutputStream to copy data toFileHandler.copy(java.io.InputStream, java.io.OutputStream, int)
public String getTmpPath(String name)
getTmpPath
in interface FileHandler
name
- The name of the directory to compute inside the tmp directory
FileHandler.getTmpPath(String)
public String createUniqueTmpDirectory()
createUniqueTmpDirectory
in interface FileHandler
FileHandler.createUniqueTmpDirectory()
public void delete(String path)
delete
in interface FileHandler
path
- the path to the file or directory to removeFileHandler.delete(String)
public InputStream getInputStream(String file)
getInputStream
in interface FileHandler
file
- the file for which to get an InputStream for
FileHandler.getInputStream(String)
public OutputStream getOutputStream(String file)
getOutputStream
in interface FileHandler
file
- the file for which to get an OutputStream for
FileHandler.getOutputStream(String)
public String append(String path, String suffixToAppend)
append
in interface FileHandler
path
- the path to append tosuffixToAppend
- the suffix to append to the path
FileHandler.append(String, String)
public void mkdirs(String path)
mkdirs
in interface FileHandler
path
- the path for which to create all directories leading to itFileHandler.mkdirs(String)
public String getParent(String path)
getParent
in interface FileHandler
path
- the path for which to return its parent
FileHandler.getParent(String)
public boolean exists(String path)
exists
in interface FileHandler
path
- the path to check the existence for
FileHandler.exists(String)
public void createFile(String file)
createFile
in interface FileHandler
file
- the file to createFileHandler.createFile(String)
public boolean isDirectoryEmpty(String dir)
isDirectoryEmpty
in interface FileHandler
dir
- the directory to check
FileHandler.isDirectoryEmpty(String)
public String getName(String file)
getName
in interface FileHandler
file
- the file name for which to return the file name
FileHandler.getName(String)
public String getURL(String path)
getURL
in interface FileHandler
path
- the path for which to return the URL
FileHandler.getURL(String)
public boolean isDirectory(String path)
isDirectory
in interface FileHandler
path
- the path to verify
FileHandler.isDirectory(String)
public String[] getChildren(String directory)
getChildren
in interface FileHandler
directory
- the directory for which to return all children
FileHandler.getChildren(String)
public String getAbsolutePath(String path)
getAbsolutePath
in interface FileHandler
path
- - what to extract the file path from
FileHandler.getAbsolutePath(String)
public String readTextFile(String file)
readTextFile
in interface FileHandler
file
- the file for which to load into a String object.
FileHandler.readTextFile(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |