com.ssh.sft
Class RegularFile

java.lang.Object
  extended bycom.ssh.sft.SftLib
      extended bycom.ssh.sft.SftBase
          extended bycom.ssh.sft.File
              extended bycom.ssh.sft.RegularFile
All Implemented Interfaces:
SftLibConstants, com.ssh.sft.SshSftFileType

public class RegularFile
extends File

A regular file. Regular files are files that contain binary data.


Field Summary
 
Fields inherited from class com.ssh.sft.File
SSH_SFT_FILE_TYPE_DIRECTORY, SSH_SFT_FILE_TYPE_REGULAR, SSH_SFT_FILE_TYPE_SPECIAL, SSH_SFT_FILE_TYPE_SYMLINK, SSH_SFT_FILE_TYPE_UNKNOWN
 
Fields inherited from interface com.ssh.sft.SftLibConstants
SSH_SFT_API_VERSION, SSH_SFT_DIR_RECURSIVE, SSH_SFT_HASH_MAX_BLOCK_SIZE, SSH_SFT_HASH_MAX_ITERATIONS, SSH_SFT_HASH_MIN_BLOCK_SIZE, SSH_SFT_REQUEST_MAX_NUM, SSH_SFT_REQUEST_MAX_SIZE
 
Constructor Summary
RegularFile()
           
 
Method Summary
 byte[] computeHash(String hashName, long offset, long len)
          Get hash of the File represented by this object.
 byte[] computeMD5()
          Get md5 hash of the File represented by this object.
 InputStream openInput()
          Opens this file and returns an InputStream for reading from the file.
 OutputStream openOutput()
          Opens this file and returns an OutputStream for writting to the file.
 InputStream openRawInput()
          Opens this file and returns an unbuffered InputStream for reading from this file.
 OutputStream openRawOutput()
          Opens this file and returns an unbuffered OutputStream for writting to this file.
 
Methods inherited from class com.ssh.sft.File
copy, copy, getAttributes, getGroup, getLocation, getOwner, getPath, getSession, getSize, getURI, move, remove, rename, setAttributes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegularFile

public RegularFile()
Method Detail

openInput

public InputStream openInput()
                      throws SftException
Opens this file and returns an InputStream for reading from the file.

Returns:
a stream for reading from this file
Throws:
SftException

openRawInput

public InputStream openRawInput()
                         throws SftException
Opens this file and returns an unbuffered InputStream for reading from this file. This method differs from openInput() only in the fact that the returned stream is unbuffered: every call to InputStream.read() involves a separate network request to the remote SFTP server.

Returns:
an unbuffered stream for reading from this file
Throws:
SftException

openRawOutput

public OutputStream openRawOutput()
                           throws SftException
Opens this file and returns an unbuffered OutputStream for writting to this file. This method differs from openOutput() only in the fact that the returned stream is unbuffered: every call to OutputStream.write(int) involves a separate network request to the remote SFTP server.

Returns:
an unbuffered stream for reading from this file
Throws:
SftException

openOutput

public OutputStream openOutput()
                        throws SftException
Opens this file and returns an OutputStream for writting to the file.

Returns:
a stream for writting to this file
Throws:
SftException

computeHash

public byte[] computeHash(String hashName,
                          long offset,
                          long len)
                   throws SftException
Get hash of the File represented by this object. This function returns the file data digest of length 'len' from 'offset'. The digest is returned. The hash algorithm name is given in 'hash_name'. Supported values for hash algorithm names are: "md5".

Parameters:
hashName - Hash algorithm name (supported: "md5").
offset - where the hash has to be calculated.
len - of the hash to be calculated.
Returns:
The file data digest.
Throws:
SftException

computeMD5

public byte[] computeMD5()
                  throws SftException
Get md5 hash of the File represented by this object. Same as calling computeHash(java.lang.String, long, long) using md5 as a hash algorithm, offset 0 and the whole file as a lenght.

Returns:
The file data digest.
Throws:
SftException