Package org.apache.commons.net.ftp

Examples of org.apache.commons.net.ftp.FTPClient.disconnect()


                try {
                    ftp.logout();
                } catch (IOException ignored) {
                }
                try {
                    ftp.disconnect();
                } catch (IOException ignored) {
                }
            }
            IOUtils.closeQuietly(input);
            IOUtils.closeQuietly(output);
View Full Code Here


        FTPClient client = savedClient;
        if (client != null) {
            savedClient = null;
            try {
                client.abort();
                client.disconnect();
            } catch (IOException ignored) {
            }
        }
        return client != null;
    }
View Full Code Here

        FTPClient client = new FTPClient();
        client.connect(host);
        String replyString = client.getReplyString();
        int replyCode = client.getReplyCode();
        if (!FTPReply.isPositiveCompletion(replyCode)) {
            client.disconnect();
            throw new IOException(replyString);
        }
        if (!client.login(username, password)) {
            replyString = client.getReplyString();
            client.logout();
View Full Code Here

        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        try {
            client.retrieveFile(path, os);
            client.logout();
        } finally {
            client.disconnect();
        }
        return new ByteArrayInputStream(os.toByteArray());
    }

}
View Full Code Here

        new File(prefix + "2.pdf").delete();
        FTPClient client = new FTPClient();
        client.connect(readConfig.getUrl());
        client.login(readConfig.getLogin(), readConfig.getPass());
        client.deleteFile("~/backup/1/1.pdf");
        client.disconnect();
        LOG.info("*****clean directories done******\n");
    }

    @Test
    public void testDirectory() throws Exception {
View Full Code Here

        cwdFtpTo(client, true);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        client.retrieveFile(filename, outputStream);
        outputStream.close();
        byte buffer[] = outputStream.toByteArray();
        client.disconnect();
        log.debug("read ftp done");
        return buffer;
    }

    protected FTPClient getClient() throws IOException {
View Full Code Here

        log.debug("FTP WRITE FINISHED, time = " + (end - start) + ", speed: " + ((data.length * 1000) / (128 * (end - start))) + "kbps");
        if (client.getReplyCode() != 226) {
            log.error("client error code:" + client.getReplyCode() + ", string:" + client.getReplyString());
            throw new IOException(client.getReplyString());
        }
        client.disconnect();
        log.trace("save to ftp done");
    }

    /**
     * go to directory where file should be append. <br>
View Full Code Here

        if (isDirectory == true)
            return true;
        FTPClient client = getClient();
        isDirectory = cwdFtpTo(client, false);
        if (isDirectory == false) {
            client.disconnect();
            return isDirectory;
        } else {
            isDirectory = client.changeWorkingDirectory(normalizedTo.split("/")[normalizedTo.split("/").length - 1]);
            client.disconnect();
            return isDirectory;
View Full Code Here

        if (isDirectory == false) {
            client.disconnect();
            return isDirectory;
        } else {
            isDirectory = client.changeWorkingDirectory(normalizedTo.split("/")[normalizedTo.split("/").length - 1]);
            client.disconnect();
            return isDirectory;
        }
    }

    public List<IPath> ls() throws IOException {
View Full Code Here

        List<IPath> rezult = new LinkedList<IPath>();
        FTPFile[] names = client.listFiles();
        for (FTPFile i : names) {
            rezult.add(new FileUtilFtpImpl(getPath() + i.getName() + (i.isDirectory() ? File.separatorChar : ""), getUsername(), getPassword(), getHost()));
        }
        client.disconnect();
        return rezult;
    }

    public IPath mkdir(String lastPathName) throws IOException {
        log.debug("FTP mkdir: to=" + this + ", lastPathName=" + lastPathName);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.