public class SftpFileSystem extends FileSystem
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEid, log, name, TIMESTAMP_FORMAT| Constructor and Description |
|---|
SftpFileSystem(String hostName,
int port)
Connects to the specified SFTP server with credentials supplied through a
CredentialsResolver (see setCredentialsResolver(CredentialsResolver)). |
SftpFileSystem(String hostName,
int port,
String userName,
String password)
Connects to the specified SFTP server.
|
SftpFileSystem(String userName,
String password)
Connects to the specified SFTP server at localhost, default port 22.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection from an SFTP server.
|
List<SftpClient.DirEntry> |
listFolder(String folderName)
Returns the contents of the folder.
|
List<SftpClient.DirEntry> |
listRootFolder()
Returns the contents of the root folder.
|
void |
open()
Opens a connection to an SFTP server.
|
InputStream |
readFile(String fileName)
Reads the specified file in the root folder.
|
InputStream |
readFile(String folderName,
String fileName)
Reads a file in the specified folder.
|
SftpFileSystem |
setCredentialsResolver(CredentialsResolver credentialsResolver)
Sets the resolver supplying this file system's user name and password
(
Credentials.USERNAME/Credentials.PASSWORD) — resolved on each open(),
never at construction, so rotated secrets are picked up on the next connection. |
OutputStream |
writeFile(String fileName)
Writes a file to the root folder.
|
OutputStream |
writeFile(String folderName,
String fileName)
Writes a file to the specified folder.
|
credentialValue, getCredentialsResolver, getCurrentCredentials, refreshCredentials, resolveCredentialsaddElapsedtime, addExceptionProperties, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getNestedEndpoint, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getRootEndpoint, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription, toStringpublic SftpFileSystem(String userName, String password)
userName - name of the userpassword - password of the userpublic SftpFileSystem(String hostName, int port, String userName, String password)
hostName - hostname of the SFTP serverport - the port to connect touserName - name of the userpassword - password of the userpublic SftpFileSystem(String hostName, int port)
CredentialsResolver (see setCredentialsResolver(CredentialsResolver)).hostName - hostname of the SFTP serverport - the port to connect topublic SftpFileSystem setCredentialsResolver(CredentialsResolver credentialsResolver)
Credentials.USERNAME/Credentials.PASSWORD) — resolved on each open(),
never at construction, so rotated secrets are picked up on the next connection. Keys absent
from the resolved credentials fall back to the constructor-supplied values.setCredentialsResolver in class FileSystempublic void open()
throws DataException
open in class EndpointDataExceptionpublic void close()
throws DataException
close in class FileSystemDataExceptionpublic InputStream readFile(String folderName, String fileName) throws Throwable
InputStream or nullThrowablepublic InputStream readFile(String fileName) throws Throwable
InputStream or nullThrowablepublic List<SftpClient.DirEntry> listFolder(String folderName) throws Throwable
Throwablepublic List<SftpClient.DirEntry> listRootFolder() throws Throwable
Throwablepublic OutputStream writeFile(String fileName) throws Throwable
fileName - the name of the fileThrowablepublic OutputStream writeFile(String folderName, String fileName) throws Throwable
folderName - the folder namefileName - the name of the fileThrowableCopyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.