|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FileHandler
File operations that are performed in Cargo. All file operations must use this interface. This interface is also useful for unit testing as it's possible to create a mock implementation of it to prevent actual file operations from happening.
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)
|
Method Detail |
---|
void copyFile(String source, String target)
source
- the file to copy from. Must not be null
.target
- the file to copy to. Must not be null
.void copyFile(String source, String target, boolean overwrite)
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.void copyFile(String source, String target, org.apache.tools.ant.types.FilterChain filterChain)
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
void copyDirectory(String source, String target)
source
- the directory to copy from. Must not be null
.target
- the directory to copy to. Must not be null
.void copyDirectory(String source, String target, List excludes)
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.String createDirectory(String parentDir, String name)
parentDir
- The directory in which the new directory should be createdname
- The name of the directory to create
void copy(InputStream in, OutputStream out, int bufSize)
in
- InputStream to copy data fromout
- OutputStream to copy data tobufSize
- size of the copy buffervoid copy(InputStream in, OutputStream out)
in
- InputStream to copy data fromout
- OutputStream to copy data toString getTmpPath(String name)
name
- The name of the directory to compute inside the tmp directory
String createUniqueTmpDirectory()
void delete(String path)
path
- the path to the file or directory to removeInputStream getInputStream(String file)
file
- the file for which to get an InputStream for
OutputStream getOutputStream(String file)
file
- the file for which to get an OutputStream for
String append(String path, String suffixToAppend)
path
- the path to append tosuffixToAppend
- the suffix to append to the path
void mkdirs(String path)
path
- the path for which to create all directories leading to itString getParent(String path)
path
- the path for which to return its parent
boolean exists(String path)
path
- the path to check the existence for
void createFile(String file)
file
- the file to createboolean isDirectoryEmpty(String dir)
dir
- the directory to check
boolean isDirectory(String path)
path
- the path to verify
String getName(String file)
file
- the file name for which to return the file name
String getURL(String path)
path
- the path for which to return the URL
String[] getChildren(String directory)
directory
- the directory for which to return all children
String getAbsolutePath(String path)
path
- - what to extract the file path from
String readTextFile(String file)
file
- the file for which to load into a String object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |