Package org.eclipse.jgit.transport
Interface FtpChannel
-
- All Known Implementing Classes:
JschSession.JschFtpChannel,SshdSession.SshdFtpChannel
public interface FtpChannelAn interface providing FTP operations over aRemoteSession. All operations are supposed to throwFtpChannel.FtpExceptionfor remote file system errors and other IOExceptions on connection errors.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceFtpChannel.DirEntrySimplified remote directory entry.static classFtpChannel.FtpExceptionAnExceptionfor reporting SFTP errors.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcd(java.lang.String path)Changes the current remote directory.voidconnect(int timeout, java.util.concurrent.TimeUnit unit)Connects theFtpChannelto the remote end.default voiddelete(java.lang.String path)Deletes a file on the remote file system.voiddisconnect()Disconnects andFtpChannel.java.io.InputStreamget(java.lang.String path)Obtain anInputStreamto read the contents of a remote file.booleanisConnected()java.util.Collection<FtpChannel.DirEntry>ls(java.lang.String path)Lists contents of a remote directoryvoidmkdir(java.lang.String path)Creates a directory on the remote file system.java.io.OutputStreamput(java.lang.String path)Obtain anOutputStreamto write to a remote file.java.lang.Stringpwd()voidrename(java.lang.String from, java.lang.String to)Renames a file on the remote file system.voidrm(java.lang.String path)Deletes a file on the remote file system.voidrmdir(java.lang.String path)Deletes a directory on the remote file system.
-
-
-
Method Detail
-
connect
void connect(int timeout, java.util.concurrent.TimeUnit unit) throws java.io.IOExceptionConnects theFtpChannelto the remote end.- Parameters:
timeout- for establishing the FTP connectionunit- of thetimeout- Throws:
java.io.IOException
-
disconnect
void disconnect()
Disconnects andFtpChannel.
-
isConnected
boolean isConnected()
- Returns:
- whether the
FtpChannelis connected
-
cd
void cd(java.lang.String path) throws java.io.IOException
Changes the current remote directory.- Parameters:
path- target directory- Throws:
java.io.IOException- if the operation could not be performed remotely
-
pwd
java.lang.String pwd() throws java.io.IOException- Returns:
- the current remote directory path
- Throws:
java.io.IOException
-
ls
java.util.Collection<FtpChannel.DirEntry> ls(java.lang.String path) throws java.io.IOException
Lists contents of a remote directory- Parameters:
path- of the directory to list- Returns:
- the directory entries
- Throws:
java.io.IOException
-
rmdir
void rmdir(java.lang.String path) throws java.io.IOExceptionDeletes a directory on the remote file system. The directory must be empty.- Parameters:
path- to delete- Throws:
java.io.IOException
-
mkdir
void mkdir(java.lang.String path) throws java.io.IOExceptionCreates a directory on the remote file system.- Parameters:
path- to create- Throws:
java.io.IOException
-
get
java.io.InputStream get(java.lang.String path) throws java.io.IOExceptionObtain anInputStreamto read the contents of a remote file.- Parameters:
path- of the file to read- Returns:
- the stream to read from
- Throws:
java.io.IOException
-
put
java.io.OutputStream put(java.lang.String path) throws java.io.IOExceptionObtain anOutputStreamto 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:
java.io.IOException
-
rm
void rm(java.lang.String path) throws java.io.IOException
Deletes a file on the remote file system.- Parameters:
path- to delete- Throws:
java.io.IOException- if the file does not exist or could otherwise not be deleted
-
delete
default void delete(java.lang.String path) throws java.io.IOExceptionDeletes a file on the remote file system. If the file does not exist, no exception is thrown.- Parameters:
path- to delete- Throws:
java.io.IOException- if the file exist but could not be deleted
-
rename
void rename(java.lang.String from, java.lang.String to) throws java.io.IOExceptionRenames a file on the remote file system. Iftoexists, it is replaced byfrom. (POSIX rename() semantics)- Parameters:
from- original name of the fileto- new name of the file- Throws:
java.io.IOException- See Also:
- stdio.h: rename()
-
-