Package org.h2.dev.ftp
Class FtpClient
java.lang.Object
org.h2.dev.ftp.FtpClient
A simple standalone FTP client.
-
Method Summary
Modifier and TypeMethodDescriptionvoidChange to the parent directory (CDUP).voidChange the working directory (CWD).voidclose()Close the connection (QUIT).booleanCheck if a file exists on the FTP server.Get the directory listing (LIST).File[]List the files on the FTP server.voidLogin to this FTP server (USER, PASS, SYST, SITE, STRU F, TYPE I).voidmakeDirectory(String dir) Create a directory (MKD).Get the directory listing (NLST).static FtpClientOpen an FTP connection.voidremoveDirectory(String dir) Remove a directory (RMD).voidRemove all files and directory in a directory, and then delete the directory itself.byte[]Read a file.voidstore(String fileName, InputStream in) Store a file (STOR).voidstoreRecursive(File file) Copy a local file or directory to the FTP server, recursively.
-
Method Details
-
open
Open an FTP connection.- Parameters:
url- the FTP URL- Returns:
- the ftp client object
- Throws:
IOException
-
login
Login to this FTP server (USER, PASS, SYST, SITE, STRU F, TYPE I).- Parameters:
userName- the user namepassword- the password- Throws:
IOException
-
close
Close the connection (QUIT).- Throws:
IOException
-
changeWorkingDirectory
Change the working directory (CWD).- Parameters:
dir- the new directory- Throws:
IOException
-
changeDirectoryUp
Change to the parent directory (CDUP).- Throws:
IOException
-
makeDirectory
Create a directory (MKD).- Parameters:
dir- the directory to create- Throws:
IOException
-
retrieve
Read a file.- Parameters:
fileName- the file name- Returns:
- the content, null if the file doesn't exist
- Throws:
IOException
-
removeDirectory
Remove a directory (RMD).- Parameters:
dir- the directory to remove- Throws:
IOException
-
removeDirectoryRecursive
Remove all files and directory in a directory, and then delete the directory itself.- Parameters:
dir- the directory to remove- Throws:
IOException
-
store
Store a file (STOR).- Parameters:
fileName- the file namein- the input stream- Throws:
IOException
-
storeRecursive
Copy a local file or directory to the FTP server, recursively.- Parameters:
file- the file to copy- Throws:
IOException
-
nameList
Get the directory listing (NLST).- Parameters:
dir- the directory- Returns:
- the listing
- Throws:
IOException
-
list
Get the directory listing (LIST).- Parameters:
dir- the directory- Returns:
- the listing
- Throws:
IOException
-
exists
Check if a file exists on the FTP server.- Parameters:
dir- the directoryname- the directory or file name- Returns:
- true if it exists
- Throws:
IOException
-
listFiles
List the files on the FTP server.- Parameters:
dir- the directory- Returns:
- the list of files
- Throws:
IOException
-