org.h2.dev.ftp

## Class FtpClient

- java.lang.Object
- - org.h2.dev.ftp.FtpClient

    public class FtpClient
    extends java.lang.Object

A simple standalone FTP client.

### Method Summary

Methods
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### open

    public static FtpClient open(java.lang.String url)
                          throws java.io.IOException

Open an FTP connection.

Parameters:
  `url` - the FTP URL
Returns:
  the ftp client object
Throws:
  `java.io.IOException`

#### login

    public void login(java.lang.String userName,
             java.lang.String password)
               throws java.io.IOException

Login to this FTP server (USER, PASS, SYST, SITE, STRU F, TYPE I).

Parameters:
  `userName` - the user name
  `password` - the password
Throws:
  `java.io.IOException`

#### close

    public void close()
               throws java.io.IOException

Close the connection (QUIT).

Throws:
  `java.io.IOException`

#### changeWorkingDirectory

    public void changeWorkingDirectory(java.lang.String dir)
                                throws java.io.IOException

Change the working directory (CWD).

Parameters:
  `dir` - the new directory
Throws:
  `java.io.IOException`

#### changeDirectoryUp

    public void changeDirectoryUp()
                           throws java.io.IOException

Change to the parent directory (CDUP).

Throws:
  `java.io.IOException`

#### makeDirectory

    public void makeDirectory(java.lang.String dir)
                       throws java.io.IOException

Create a directory (MKD).

Parameters:
  `dir` - the directory to create
Throws:
  `java.io.IOException`

#### retrieve

    public byte[] retrieve(java.lang.String fileName)
                    throws java.io.IOException

Read a file.

Parameters:
  `fileName` - the file name
Returns:
  the content, null if the file doesn't exist
Throws:
  `java.io.IOException`

#### removeDirectory

    public void removeDirectory(java.lang.String dir)
                         throws java.io.IOException

Remove a directory (RMD).

Parameters:
  `dir` - the directory to remove
Throws:
  `java.io.IOException`

#### removeDirectoryRecursive

    public void removeDirectoryRecursive(java.lang.String dir)
                                  throws java.io.IOException

Remove all files and directory in a directory, and then delete the directory itself.

Parameters:
  `dir` - the directory to remove
Throws:
  `java.io.IOException`

#### store

    public void store(java.lang.String fileName,
             java.io.InputStream in)
               throws java.io.IOException

Store a file (STOR).

Parameters:
  `fileName` - the file name
  `in` - the input stream
Throws:
  `java.io.IOException`

#### storeRecursive

    public void storeRecursive(java.io.File file)
                        throws java.io.IOException

Copy a local file or directory to the FTP server, recursively.

Parameters:
  `file` - the file to copy
Throws:
  `java.io.IOException`

#### nameList

    public java.lang.String nameList(java.lang.String dir)
                              throws java.io.IOException

Get the directory listing (NLST).

Parameters:
  `dir` - the directory
Returns:
  the listing
Throws:
  `java.io.IOException`

#### list

    public java.lang.String list(java.lang.String dir)
                          throws java.io.IOException

Get the directory listing (LIST).

Parameters:
  `dir` - the directory
Returns:
  the listing
Throws:
  `java.io.IOException`

#### exists

    public boolean exists(java.lang.String dir,
                 java.lang.String name)
                   throws java.io.IOException

Check if a file exists on the FTP server.

Parameters:
  `dir` - the directory
  `name` - the directory or file name
Returns:
  true if it exists
Throws:
  `java.io.IOException`

#### listFiles

    public java.io.File[] listFiles(java.lang.String dir)
                             throws java.io.IOException

List the files on the FTP server.

Parameters:
  `dir` - the directory
Returns:
  the list of files
Throws:
  `java.io.IOException`