Package com.sshtools.client.sftp
Class SftpClient.SftpClientBuilder
java.lang.Object
com.sshtools.client.sftp.SftpClient.SftpClientBuilder
- Enclosing class:
- SftpClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a newSftpClient.static SftpClient.SftpClientBuildercreate()Create a newSftpClient.SftpClientBuilder.withAsyncRequests(int asyncRequests) Set the maximum number of asynchronous requests to use for optimised reads and writes to remote files.withBlockSize(int blockSize) Sets the block size used when transferring files, defaults to the optimized setting of 32768.withBufferSize(int bufferSize) Set the size of the buffer which is used to read from the local file system.withClient(SshClient client) Use an existingSshClientto create theSftpClient.withConnection(SshConnection connection) Use an existingSshConnectionto create theSftpClient.withCustomRoots(String... rootPaths) Adds one or more custom file system root paths.withFileFactory(AbstractFileFactory<?> fileFactory) Use a specificAbstractFileFactoryfor this client.withLocalHome(File localRoot) Use a specificPathas the home of the local file system.withLocalHome(Path localHome) Use a specificPathas the home of the local file system.withLocalHomeSandbox(boolean localHomeSandbox) Whether or not to sandbox the path provided as the Local Home/code>.withLocalPath(String localPath) Start off in a specified local path.withRemotePath(String remotePath) Start off in a specified remote path.Set to not sandbox the path provided as the Local Home/code>.
-
Constructor Details
-
SftpClientBuilder
public SftpClientBuilder()
-
-
Method Details
-
create
Create a newSftpClient.SftpClientBuilder.- Returns:
- builder
-
withCustomRoots
Adds one or more custom file system root paths. Some devices have unusual file system roots such as "flash:", customRoots contains these. If a device uses roots like this, and folder traversal on the device is required then it must have its root stored in customRoots- Parameters:
rootPaths- root paths- See Also:
-
SftpClientBuilder#withCustomRoots(String)
-
withConnection
Use an existingSshConnectionto create theSftpClient.- Parameters:
connection- connection- Returns:
- this for chaining
-
withClient
Use an existingSshClientto create theSftpClient.- Parameters:
client- client- Returns:
- this for chaining
-
withFileFactory
Use a specificAbstractFileFactoryfor this client.- Parameters:
factory- factory- Returns:
- this for chaining
-
withLocalHomeSandbox
Whether or not to sandbox the path provided as the Local Home/code>. default this istrue. Will only be used whenwithLocalHome(Path)orwithLocalHome(File)have been used, andwithFileFactory(AbstractFileFactory)has not been used. -
withWithoutLocalHomeSandbox
Set to not sandbox the path provided as the Local Home/code>. default this istrue. Will only be used whenwithLocalHome(Path)orwithLocalHome(File)have been used, andwithFileFactory(AbstractFileFactory)has not been used. -
withRemotePath
Start off in a specified remote path. Any subsequent relative remote paths would then be resolved against this path. The path may be changed at runtime usingSftpClient.cd(String).- Parameters:
path- path- Returns:
- this for chaining
-
withLocalPath
Start off in a specified local path. Any subsequent relative remote paths would then be resolved against this path. The path may be changed at runtime usingSftpClient.lcd(String).- Parameters:
path- path- Returns:
- this for chaining
-
withLocalHome
Use a specificPathas the home of the local file system. Will only be used ifwithFileFactory(AbstractFileFactory)has not been used. If not provided, the current user's home directory (i.e.System.getProperty("user.home");) will be used.Use of this method will replace the currently configured
AbstractFileFactoryif any.- Parameters:
localHome- local root path- Returns:
- this for chaining
-
withLocalHome
Use a specificPathas the home of the local file system. Will only be used ifwithFileFactory(AbstractFileFactory)has not been used. If not provided, the current user's home directory (i.e.System.getProperty("user.home");) will be used.Use of this method will replace the currently configured
AbstractFileFactoryif any.- Parameters:
localRoot- local root path- Returns:
- this for chaining
-
withBlockSize
Sets the block size used when transferring files, defaults to the optimized setting of 32768. You should not increase this value as the remote server may not be able to support higher blocksizes.- Parameters:
blockSize- block size
-
withBufferSize
Set the size of the buffer which is used to read from the local file system. This setting is used to optimize the writing of files by allowing for a large chunk of data to be read in one operation from a local file. The previous version simply read each block of data before sending however this decreased performance, this version now reads the file into a temporary buffer in order to reduce the number of local filesystem reads. This increases performance and so this setting should be set to the highest value possible. The default setting is negative which means the entire file will be read into a temporary buffer.- Parameters:
bufferSize- buffer size
-
withAsyncRequests
Set the maximum number of asynchronous requests to use for optimised reads and writes to remote files. When not provided, this will be calculate from the remote window size and the block size.- Parameters:
asyncRequests- max async requests
-
build
Build a newSftpClient.- Returns:
- sftp client
- Throws:
SshException- on SSH errorIOException- on I/O errorPermissionDeniedException- on permissions error
-