Java Code Examples for org.apache.commons.net.ftp.FTPClient#setBufferSize()

The following examples show how to use org.apache.commons.net.ftp.FTPClient#setBufferSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FTPClientFactory.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
public PooledObject<FTPClient> makeObject() throws Exception {
    FTPClient ftpClient = new FTPClient();
    ftpClient.setConnectTimeout(config.getClientTimeout());
    ftpClient.connect(config.getHost(), config.getPort());
    int reply = ftpClient.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply)) {
        ftpClient.disconnect();
        logger.warn("FTPServer refused connection");
        return null;
    }
    boolean result = ftpClient.login(config.getUsername(), config.getPassword());
    if (!result) {
        throw new ConnectException("ftp登陆失败:" + config.getUsername() + "/password:" + config.getPassword() + "@" + config.getHost());
    }
    ftpClient.setFileType(config.getTransferFileType());
    ftpClient.setBufferSize(1024);
    ftpClient.setControlEncoding(config.getEncoding());
    if (config.isPassiveMode()) {
        ftpClient.enterLocalPassiveMode();
    }
    return new DefaultPooledObject<>(ftpClient);

}
 
Example 2
Source File: FtpClientManager.java    From onetwo with Apache License 2.0 5 votes vote down vote up
public void init() {
	if(initialized){
		return ;
	}
	
	FTPClient ftpClient = new FTPClient();
	ftpClient.setControlEncoding(ftpConfig.getEncoding());
	ftpClient.setBufferSize(ftpConfig.getBufferSize());
	ftpClient.setPassiveNatWorkaround(ftpConfig.isPasv());
	
	this.ftpClient = ftpClient;
	this.initialized = true;
}
 
Example 3
Source File: FtpClientUtils.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
public FtpClientUtils() {
	ftpClient = new FTPClient();
	ftpClient.setBufferSize(100000);
}