public class FtpClient
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
changeDirectoryUp()
Change to the parent directory (CDUP).
|
void |
changeWorkingDirectory(java.lang.String dir)
Change the working directory (CWD).
|
void |
close()
Close the connection (QUIT).
|
boolean |
exists(java.lang.String dir,
java.lang.String name)
Check if a file exists on the FTP server.
|
java.lang.String |
list(java.lang.String dir)
Get the directory listing (LIST).
|
java.io.File[] |
listFiles(java.lang.String dir)
List the files on the FTP server.
|
void |
login(java.lang.String userName,
java.lang.String password)
Login to this FTP server (USER, PASS, SYST, SITE, STRU F, TYPE I).
|
void |
makeDirectory(java.lang.String dir)
Create a directory (MKD).
|
java.lang.String |
nameList(java.lang.String dir)
Get the directory listing (NLST).
|
static FtpClient |
open(java.lang.String url)
Open an FTP connection.
|
void |
removeDirectory(java.lang.String dir)
Remove a directory (RMD).
|
void |
removeDirectoryRecursive(java.lang.String dir)
Remove all files and directory in a directory, and then delete the
directory itself.
|
byte[] |
retrieve(java.lang.String fileName)
Read a file.
|
void |
store(java.lang.String fileName,
java.io.InputStream in)
Store a file (STOR).
|
void |
storeRecursive(java.io.File file)
Copy a local file or directory to the FTP server, recursively.
|
public static FtpClient open(java.lang.String url) throws java.io.IOException
url - the FTP URLjava.io.IOExceptionpublic void login(java.lang.String userName,
java.lang.String password)
throws java.io.IOException
userName - the user namepassword - the passwordjava.io.IOExceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionpublic void changeWorkingDirectory(java.lang.String dir)
throws java.io.IOException
dir - the new directoryjava.io.IOExceptionpublic void changeDirectoryUp()
throws java.io.IOException
java.io.IOExceptionpublic void makeDirectory(java.lang.String dir)
throws java.io.IOException
dir - the directory to createjava.io.IOExceptionpublic byte[] retrieve(java.lang.String fileName)
throws java.io.IOException
fileName - the file namejava.io.IOExceptionpublic void removeDirectory(java.lang.String dir)
throws java.io.IOException
dir - the directory to removejava.io.IOExceptionpublic void removeDirectoryRecursive(java.lang.String dir)
throws java.io.IOException
dir - the directory to removejava.io.IOExceptionpublic void store(java.lang.String fileName,
java.io.InputStream in)
throws java.io.IOException
fileName - the file namein - the input streamjava.io.IOExceptionpublic void storeRecursive(java.io.File file)
throws java.io.IOException
file - the file to copyjava.io.IOExceptionpublic java.lang.String nameList(java.lang.String dir)
throws java.io.IOException
dir - the directoryjava.io.IOExceptionpublic java.lang.String list(java.lang.String dir)
throws java.io.IOException
dir - the directoryjava.io.IOExceptionpublic boolean exists(java.lang.String dir,
java.lang.String name)
throws java.io.IOException
dir - the directoryname - the directory or file namejava.io.IOExceptionpublic java.io.File[] listFiles(java.lang.String dir)
throws java.io.IOException
dir - the directoryjava.io.IOException