net.sf.commons.ssh
Interface SftpSession

All Superinterfaces:
Session

public interface SftpSession
extends Session

Since:
1.2
Author:
Egor Ivanov (crackcraft at gmail dot com)
See Also:
Features.SESSION_SFTP

Method Summary
 void cd(java.lang.String dir)
          Changes the working directory on the remote server.
 void chgrp(int gid, java.lang.String path)
          Sets the group ID for the file or directory.
 void chmod(int permissions, java.lang.String path)
          Changes the access permissions or modes of the specified file or directory.
 void chown(int uid, java.lang.String path)
          Sets the user ID to owner for the file or directory.
 void get(java.lang.String path)
          Download the remote file to the local computer.
 void get(java.lang.String remote, java.io.OutputStream local)
          Download the remote file writing it to the specified OutputStream.
 void get(java.lang.String remote, java.lang.String local)
          Download the remote file to the local computer.
 java.lang.String getAbsolutePath(java.lang.String path)
           
 void lcd(java.lang.String path)
          Changes the local working directory.
 java.lang.String lpwd()
          Returns the absolute path to the local working directory.
 java.util.List ls()
          List the contents of the current remote working directory.
 java.util.List ls(java.lang.String path)
          List the contents remote directory.
 void mkdir(java.lang.String dir)
          Creates a new directory on the remote server.
 void put(java.io.InputStream in, java.lang.String remote)
           
 void put(java.lang.String local)
          Upload a file to the remote computer.
 void put(java.lang.String local, java.lang.String remote)
          Upload a file to the remote computer.
 java.lang.String pwd()
          Returns the absolute path name of the current remote working directory.
 void rename(java.lang.String oldpath, java.lang.String newpath)
          Rename a file on the remote computer.
 void rm(java.lang.String path)
          Remove a file or directory from the remote computer.
 SftpFileAttributes stat(java.lang.String path)
          Returns the attributes of the file from the remote computer.
 void symlink(java.lang.String path, java.lang.String link)
          Create a symbolic link on the remote computer.
 void umask(int umask)
          Sets the defaultPermissions used by this client.
 
Methods inherited from interface net.sf.commons.ssh.Session
close, isClosed
 

Method Detail

cd

void cd(java.lang.String dir)
        throws java.io.IOException
Changes the working directory on the remote server.

Parameters:
dir - the new working directory
Throws:
java.io.IOException - if an IO error occurs or the file does not exist
java.io.FileNotFoundException

chgrp

void chgrp(int gid,
           java.lang.String path)
           throws java.io.IOException
Sets the group ID for the file or directory.

Parameters:
gid - the numeric group id for the new group
path - the path to the remote file/directory
Throws:
java.io.IOException - if an IO error occurs or the file does not exist

chmod

void chmod(int permissions,
           java.lang.String path)
           throws java.io.IOException
Changes the access permissions or modes of the specified file or directory. Modes determine who can read, change or execute a file.
 Absolute modes are octal numbers specifying the complete list of
 attributes for the files; you specify attributes by OR'ing together
 these bits.
 
 0400       Individual read
 0200       Individual write
 0100       Individual execute (or list directory)
 0040       Group read
 0020       Group write
 0010       Group execute
 0004       Other read
 0002       Other write
 0001       Other execute
 

Parameters:
permissions - the absolute mode of the file/directory
path - the path to the file/directory on the remote server
Throws:
java.io.IOException - if an IO error occurs or the file if not found

chown

void chown(int uid,
           java.lang.String path)
           throws java.io.IOException
Sets the user ID to owner for the file or directory.

Parameters:
uid - numeric user id of the new owner
path - the path to the remote file/directory
Throws:
java.io.IOException - if an IO error occurs or the file does not exist

get

void get(java.lang.String path)
         throws java.io.IOException
Download the remote file to the local computer.

Parameters:
path - the path to the remote file
Throws:
java.io.IOException - if an IO error occurs of the file does not exist

get

void get(java.lang.String remote,
         java.io.OutputStream local)
         throws java.io.IOException
Download the remote file writing it to the specified OutputStream. The OutputStream is closed by this method even if the operation fails.

Parameters:
remote - the path/name of the remote file
local - the OutputStream to write
Throws:
java.io.IOException - if an IO error occurs or the file does not exist

get

void get(java.lang.String remote,
         java.lang.String local)
         throws java.io.IOException
Download the remote file to the local computer. If the paths provided are not absolute the current working directory is used.

Parameters:
remote - the path/name of the remote file
local - the path/name of the local file
Throws:
java.io.IOException

getAbsolutePath

java.lang.String getAbsolutePath(java.lang.String path)
                                 throws java.io.IOException
Parameters:
path -
Returns:
Throws:
java.io.IOException

lcd

void lcd(java.lang.String path)
         throws java.io.IOException
Changes the local working directory.

Parameters:
path - the path to the new working directory
Throws:
java.io.IOException - if an IO error occurs

lpwd

java.lang.String lpwd()
Returns the absolute path to the local working directory.

Returns:
the absolute path of the local working directory.

ls

java.util.List ls()
                  throws java.io.IOException
List the contents of the current remote working directory.

Returns:
a list of SftpFile for the current working directory
Throws:
java.io.IOException - if an IO error occurs
See Also:
SftpFile

ls

java.util.List ls(java.lang.String path)
                  throws java.io.IOException
List the contents remote directory.

Parameters:
path - the path on the remote server to list
Returns:
a list of SftpFile for the remote directory
Throws:
java.io.IOException - if an IO error occurs
See Also:
SftpFile

mkdir

void mkdir(java.lang.String dir)
           throws java.io.IOException
Creates a new directory on the remote server. This method will throw an exception if the directory already exists. To create directories and disregard any errors use the mkdirs method.

Parameters:
dir - the name of the new directory
Throws:
java.io.IOException - if an IO error occurs or if the directory already exists

put

void put(java.io.InputStream in,
         java.lang.String remote)
         throws java.io.IOException
Parameters:
in -
remote -
Throws:
java.io.IOException

put

void put(java.lang.String local)
         throws java.io.IOException
Upload a file to the remote computer.

Parameters:
local - the path/name of the local file
Throws:
java.io.IOException - if an IO error occurs or the file does not exist

put

void put(java.lang.String local,
         java.lang.String remote)
         throws java.io.IOException
Upload a file to the remote computer. If the paths provided are not absolute the current working directory is used.

Parameters:
local - the path/name of the local file
remote - the path/name of the destination file
Throws:
java.io.IOException - if an IO error occurs or the file does not exist

pwd

java.lang.String pwd()
                     throws java.io.IOException
Returns the absolute path name of the current remote working directory.

Returns:
the absolute path of the remote working directory.
Throws:
java.io.IOException

rename

void rename(java.lang.String oldpath,
            java.lang.String newpath)
            throws java.io.IOException
Rename a file on the remote computer.

Parameters:
oldpath - the old path
newpath - the new path
Throws:
java.io.IOException - if an IO error occurs

rm

void rm(java.lang.String path)
        throws java.io.IOException
Remove a file or directory from the remote computer.

Parameters:
path - the path of the remote file/directory
Throws:
java.io.IOException - if an IO error occurs

stat

SftpFileAttributes stat(java.lang.String path)
                        throws java.io.IOException
Returns the attributes of the file from the remote computer.

Parameters:
path - the path of the file on the remote computer
Returns:
the attributes
Throws:
java.io.IOException - if an IO error occurs or the file does not exist
See Also:
SftpFileAttributes

symlink

void symlink(java.lang.String path,
             java.lang.String link)
             throws java.io.IOException
Create a symbolic link on the remote computer.

Parameters:
path - the path to the existing file
link - the new link
Throws:
java.io.IOException - if an IO error occurs or the operation is not supported on the remote platform

umask

void umask(int umask)
Sets the defaultPermissions used by this client.

Parameters:
umask -


Copyright © 2009. All Rights Reserved.