public interface FtpChannel
An interface providing FTP operations over a
RemoteSession
. All
operations are supposed to throw FtpChannel.FtpException
for remote file system
errors and other IOExceptions on connection errors.- Since:
- 5.2
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Simplified remote directory entry.static class
AnException
for reporting SFTP errors. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Changes the current remote directory.void
Connects theFtpChannel
to the remote end.default void
Deletes a file on the remote file system.void
Disconnects andFtpChannel
.Obtain anInputStream
to read the contents of a remote file.boolean
Whether the FtpChannel is connectedLists contents of a remote directoryvoid
Creates a directory on the remote file system.Obtain anOutputStream
to write to a remote file.pwd()
Get current remote directory pathvoid
Renames a file on the remote file system.void
Deletes a file on the remote file system.void
Deletes a directory on the remote file system.
-
Method Details
-
connect
Connects theFtpChannel
to the remote end.- Parameters:
timeout
- for establishing the FTP connectionunit
- of thetimeout
- Throws:
IOException
- if an IO error occurred
-
disconnect
void disconnect()Disconnects andFtpChannel
. -
isConnected
boolean isConnected()Whether the FtpChannel is connected- Returns:
- whether the
FtpChannel
is connected
-
cd
Changes the current remote directory.- Parameters:
path
- target directory- Throws:
IOException
- if the operation could not be performed remotely
-
pwd
Get current remote directory path- Returns:
- the current remote directory path
- Throws:
IOException
- if an IO error occurred
-
ls
Lists contents of a remote directory- Parameters:
path
- of the directory to list- Returns:
- the directory entries
- Throws:
IOException
- if an IO error occurred
-
rmdir
Deletes a directory on the remote file system. The directory must be empty.- Parameters:
path
- to delete- Throws:
IOException
- if an IO error occurred
-
mkdir
Creates a directory on the remote file system.- Parameters:
path
- to create- Throws:
IOException
- if an IO error occurred
-
get
Obtain anInputStream
to read the contents of a remote file.- Parameters:
path
- of the file to read- Returns:
- the stream to read from
- Throws:
IOException
- if an IO error occurred
-
put
Obtain anOutputStream
to write to a remote file. If the file exists already, it will be overwritten.- Parameters:
path
- of the file to read- Returns:
- the stream to read from
- Throws:
IOException
- if an IO error occurred
-
rm
Deletes a file on the remote file system.- Parameters:
path
- to delete- Throws:
IOException
- if the file does not exist or could otherwise not be deleted
-
delete
Deletes a file on the remote file system. If the file does not exist, no exception is thrown.- Parameters:
path
- to delete- Throws:
IOException
- if the file exist but could not be deleted
-
rename
Renames a file on the remote file system. Ifto
exists, it is replaced byfrom
. (POSIX rename() semantics)- Parameters:
from
- original name of the fileto
- new name of the file- Throws:
IOException
- if an IO error occurred- See Also:
-