Package com.trilead.ssh2.jenkins
Class SFTPClient
- java.lang.Object
-
- com.trilead.ssh2.SFTPv3Client
-
- com.trilead.ssh2.jenkins.SFTPClient
-
public class SFTPClient extends SFTPv3Client
This Class adds file manage capabilities to the SFTPv3Client class.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description SFTPClient(Connection conn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SFTPv3FileAttributes
_stat(java.lang.String path)
GracefulSFTPv3Client.stat(String)
that returns null if the path doesn't exist.void
chmod(java.lang.String path, int permissions)
Change file or directory permissions.boolean
exists(java.lang.String path)
Checks if the given path exists.void
mkdirs(java.lang.String path, int posixPermission)
Makes sure that the directory exists, by creating it if necessary.java.io.InputStream
read(java.lang.String file)
Read input stream.java.io.OutputStream
writeToFile(java.lang.String path)
Creates a new file and writes to it.-
Methods inherited from class com.trilead.ssh2.SFTPv3Client
canonicalPath, close, closeFile, createFile, createFile, createFileTruncate, createFileTruncate, createSymlink, fsetstat, fstat, getCharset, getProtocolVersion, ls, lstat, mkdir, mv, openFileRO, openFileRW, read, readLink, rm, rmdir, setCharset, setstat, stat, write
-
-
-
-
Constructor Detail
-
SFTPClient
public SFTPClient(Connection conn) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
exists
public boolean exists(java.lang.String path) throws java.io.IOException
Checks if the given path exists.- Overrides:
exists
in classSFTPv3Client
- Parameters:
path
- directory or file path.- Returns:
- true if it exists.
- Throws:
java.io.IOException
- if it is not possible to access to the directory or file .
-
_stat
public SFTPv3FileAttributes _stat(java.lang.String path) throws java.io.IOException
GracefulSFTPv3Client.stat(String)
that returns null if the path doesn't exist.- Overrides:
_stat
in classSFTPv3Client
- Parameters:
path
- directory path.- Returns:
- the sft pv 3 file attributes
- Throws:
java.io.IOException
- if it is not possible to access to the directory.
-
mkdirs
public void mkdirs(java.lang.String path, int posixPermission) throws java.io.IOException
Makes sure that the directory exists, by creating it if necessary.- Overrides:
mkdirs
in classSFTPv3Client
- Parameters:
path
- directory path.posixPermission
- POSIX permissions.- Throws:
java.io.IOException
- if it is not possible to access to the directory.
-
writeToFile
public java.io.OutputStream writeToFile(java.lang.String path) throws java.io.IOException
Description copied from class:SFTPv3Client
Creates a new file and writes to it.- Overrides:
writeToFile
in classSFTPv3Client
- Parameters:
path
- file path.- Returns:
- Creates a new file and return an OutputStream to writes to it.
- Throws:
java.io.IOException
- if it is not possible to access to the file.
-
read
public java.io.InputStream read(java.lang.String file) throws java.io.IOException
Description copied from class:SFTPv3Client
Read input stream.- Overrides:
read
in classSFTPv3Client
- Parameters:
file
- file path.- Returns:
- return an InputStream to the file.
- Throws:
java.io.IOException
- if it is not possible to access to the file.
-
chmod
public void chmod(java.lang.String path, int permissions) throws java.io.IOException
Change file or directory permissions.- Overrides:
chmod
in classSFTPv3Client
- Parameters:
path
- file or directory path.permissions
- POSIX permissions.- Throws:
java.io.IOException
- in case of error.
-
-