http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.htmlJava Apache FTPClient API : finally 절에서 logout()이 왜 안되나요?
내가 마지막 절에서 예를 연결 해제()을 발견,하지만 우리가 로그 아웃 할 필요가 없습니다 이유를 아는 사람
FTPClient ftp = new FTPClient();
FTPClientConfig config = new FTPClientConfig();
config.setXXX(YYY); // change required options
ftp.configure(config);
boolean error = false;
try {
int reply;
ftp.connect("ftp.foobar.com");
System.out.println("Connected to " + server + ".");
System.out.print(ftp.getReplyString());
// After connection attempt, you should check the reply code to verify
// success.
reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
... // transfer files
ftp.logout();
} catch(IOException e) {
error = true;
e.printStackTrace();
} finally {
if(ftp.isConnected()) {
try {
ftp.disconnect();
} catch(IOException ioe) {
// do nothing
}
}
System.exit(error ? 1 : 0);
}
로그 아웃()에 대해 동일한 작업을 수행하지 않습니다() 할 때 우리가 예외를 잡았나요?
를하는 것이 바람직하기 때문에 또한
disconnect()
함수는 또한 예외가 발생하지만,이logout()
기능하지 않는input, output, socket
해제 자원을 닫는다. :) – Sage