Example usage for org.apache.commons.net.ftp FTPClient removeDirectory

List of usage examples for org.apache.commons.net.ftp FTPClient removeDirectory

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPClient removeDirectory.

Prototype

public boolean removeDirectory(String pathname) throws IOException 

Source Link

Document

Removes a directory on the FTP server (if empty).

Usage

From source file:view.GenerujTest.java

private void sendfile() {

    FTPClient client = new FTPClient();
    FileInputStream fis = null;//from   w ww.j a  v a 2s.co  m

    try {
        client.connect("ftp.serwer1749827.home.pl");
        client.login("serwer", "serwer123456");

        //
        // Create an InputStream of the file to be uploaded
        //
        client.removeDirectory("index.html");
        String filename = "index.html";
        fis = new FileInputStream(filename);

        //
        // Store file to server
        //
        client.storeFile(filename, fis);
        client.logout();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
            client.disconnect();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}