Package org.eclipse.jgit.transport
Interface FtpChannel
-
public interface FtpChannel
An interface providing FTP operations over aRemoteSession
. All operations are supposed to throwFtpChannel.FtpException
for remote file system errors and other IOExceptions on connection errors.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
FtpChannel.DirEntry
Simplified remote directory entry.static class
FtpChannel.FtpException
AnException
for reporting SFTP errors.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
cd(String path)
Changes the current remote directory.void
connect(int timeout, TimeUnit unit)
Connects theFtpChannel
to the remote end.default void
delete(String path)
Deletes a file on the remote file system.void
disconnect()
Disconnects andFtpChannel
.InputStream
get(String path)
Obtain anInputStream
to read the contents of a remote file.boolean
isConnected()
Collection<FtpChannel.DirEntry>
ls(String path)
Lists contents of a remote directoryvoid
mkdir(String path)
Creates a directory on the remote file system.OutputStream
put(String path)
Obtain anOutputStream
to write to a remote file.String
pwd()
void
rename(String from, String to)
Renames a file on the remote file system.void
rm(String path)
Deletes a file on the remote file system.void
rmdir(String path)
Deletes a directory on the remote file system.
-
-
-
Method Detail
-
connect
void connect(int timeout, TimeUnit unit) throws IOException
Connects theFtpChannel
to the remote end.- Parameters:
timeout
- for establishing the FTP connectionunit
- of thetimeout
- Throws:
IOException
-
disconnect
void disconnect()
Disconnects andFtpChannel
.
-
isConnected
boolean isConnected()
- Returns:
- whether the
FtpChannel
is connected
-
cd
void cd(String path) throws IOException
Changes the current remote directory.- Parameters:
path
- target directory- Throws:
IOException
- if the operation could not be performed remotely
-
pwd
String pwd() throws IOException
- Returns:
- the current remote directory path
- Throws:
IOException
-
ls
Collection<FtpChannel.DirEntry> ls(String path) throws IOException
Lists contents of a remote directory- Parameters:
path
- of the directory to list- Returns:
- the directory entries
- Throws:
IOException
-
rmdir
void rmdir(String path) throws IOException
Deletes a directory on the remote file system. The directory must be empty.- Parameters:
path
- to delete- Throws:
IOException
-
mkdir
void mkdir(String path) throws IOException
Creates a directory on the remote file system.- Parameters:
path
- to create- Throws:
IOException
-
get
InputStream get(String path) throws IOException
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
-
put
OutputStream put(String path) throws IOException
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
-
rm
void rm(String path) throws IOException
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
default void delete(String path) throws IOException
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
void rename(String from, String to) throws IOException
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
- See Also:
- stdio.h: rename()
-
-