com.xebialabs.deployit.hostsession
Class HostFileUtils

java.lang.Object
  extended by com.xebialabs.deployit.hostsession.HostFileUtils

public class HostFileUtils
extends java.lang.Object

Contains a number of convenience methods for working with HostFile objects.


Constructor Summary
HostFileUtils()
           
 
Method Summary
static void copy(HostFile src, HostFile dst)
          Copies a file or directory.
static void copy(HostFile src, HostFile dst, HostFileInputStreamTransformer transformer)
          Copies a file or directory.
static void copyDirectory(HostFile srcDir, HostFile dstDir)
          Copies a directory recursively.
static void copyDirectory(HostFile srcDir, HostFile dstDir, HostFileInputStreamTransformer transformer)
          Copies a directory recursively.
static void copyFile(HostFile srcFile, HostFile dstFile)
          Copies a regular file.
static void copyFile(HostFile srcFile, HostFile dstFile, HostFileInputStreamTransformer transformer)
          Copies a regular file.
static java.lang.String getHostFileAsString(HostFile sourceHostFile)
          Reads the contents of a HostFile as a string.
static void putStringToHostFile(java.lang.String sourceString, HostFile targetFile)
          Copies the contents of a string to a HostFile.
static void unzip(HostFile zip, HostFile dir)
          Unzips a host file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostFileUtils

public HostFileUtils()
Method Detail

copy

public static void copy(HostFile src,
                        HostFile dst)
Copies a file or directory.

Parameters:
src - the source file or directory.
dst - the destination file or directory. If it exists it must be of the same type as the source. Its parent directory must exist.
Throws:
RuntimeIOException - if an I/O error occurred

copy

public static void copy(HostFile src,
                        HostFile dst,
                        HostFileInputStreamTransformer transformer)
Copies a file or directory.

Parameters:
src - the source file or directory.
dst - the destination file or directory. If it exists it must be of the same type as the source. Its parent directory must exist.
transformer - Transforms the inputstream of the sourcefile, can supply null
Throws:
RuntimeIOException - if an I/O error occurred

copyFile

public static void copyFile(HostFile srcFile,
                            HostFile dstFile)
                     throws RuntimeIOException
Copies a regular file.

Parameters:
srcFile - the source file. Must exists and must not be a directory.
dstFile - the destination file. May exists but must not be a directory. Its parent directory must exist.
Throws:
RuntimeIOException - if an I/O error occurred

copyFile

public static void copyFile(HostFile srcFile,
                            HostFile dstFile,
                            HostFileInputStreamTransformer transformer)
                     throws RuntimeIOException
Copies a regular file.

Parameters:
srcFile - the source file. Must exists and must not be a directory.
dstFile - the destination file. May exists but must not be a directory. Its parent directory must exist.
transformer - Transforms the inputstream of the sourcefile, can be null
Throws:
RuntimeIOException - if an I/O error occurred

copyDirectory

public static void copyDirectory(HostFile srcDir,
                                 HostFile dstDir)
                          throws RuntimeIOException
Copies a directory recursively.

Parameters:
srcDir - the source directory. Must exist and must not be a directory.
dstDir - the destination directory. May exists but must a directory. Its parent directory must exist.
Throws:
RuntimeIOException - if an I/O error occurred

copyDirectory

public static void copyDirectory(HostFile srcDir,
                                 HostFile dstDir,
                                 HostFileInputStreamTransformer transformer)
                          throws RuntimeIOException
Copies a directory recursively.

Parameters:
srcDir - the source directory. Must exist and must not be a directory.
dstDir - the destination directory. May exists but must a directory. Its parent directory must exist.
transformer - Transforms the inputstream of the sourcefile, can be null
Throws:
RuntimeIOException - if an I/O error occurred

putStringToHostFile

public static void putStringToHostFile(java.lang.String sourceString,
                                       HostFile targetFile)
Copies the contents of a string to a HostFile.

Parameters:
sourceString - the string to copy.
targetFile - the host file to copy to.

getHostFileAsString

public static java.lang.String getHostFileAsString(HostFile sourceHostFile)
Reads the contents of a HostFile as a string.

Parameters:
sourceHostFile - the host file to read.
Returns:
the contents of the host file.

unzip

public static void unzip(HostFile zip,
                         HostFile dir)
Unzips a host file.

Parameters:
zip - the file to unzip.
dir - the directory to unzip to.


Copyright © 2010. All Rights Reserved.