Skip to content

Commit

Permalink
增加自定义设置方法
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Aug 30, 2017
1 parent 1333cac commit 72e62cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.hswebframework.expands.request.ftp;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.function.Consumer;

/**
* Created by zhouhao on 16-6-24.
Expand Down Expand Up @@ -41,4 +43,5 @@ public interface FtpRequest {

void download(String name, OutputStream outputStream) throws IOException;

FtpRequest setting(Consumer<FTPClient> clientConsumer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class SimpleFtpRequest implements FtpRequest {
private Logger logger = LoggerFactory.getLogger(FtpRequest.class);
Expand All @@ -37,6 +38,11 @@ public SimpleFtpRequest(String addr, int port, String username, String password)
}
}

public FtpRequest setting(Consumer<FTPClient> clientConsumer) {
clientConsumer.accept(ftp);
return this;
}

@Override
public FtpRequest encode(String encode) {
ftp.setControlEncoding(encode);
Expand Down

0 comments on commit 72e62cb

Please sign in to comment.