1 25 package org.archive.net; 26 27 28 import java.io.IOException ; 29 import java.net.Socket ; 30 31 import org.apache.commons.net.ftp.FTPClient; 32 import org.apache.commons.net.ftp.FTPReply; 33 34 35 54 public class ClientFTP extends FTPClient { 55 56 57 60 public ClientFTP() { 61 } 62 63 64 72 public void connectStrict(String host, int port) throws IOException { 73 this.connect(host, port); 74 int reply = this.getReplyCode(); 75 if (!FTPReply.isPositiveCompletion(reply)) { 76 throw new FTPException(reply); 77 } 78 } 79 80 81 92 public void loginStrict(String user, String pass) throws IOException { 93 boolean r = this.login(user, pass); 94 if (!r) { 95 throw new FTPException(this.getReplyCode()); 96 } 97 } 98 99 100 109 public void setBinary() throws IOException { 110 boolean r = super.setFileType(BINARY_FILE_TYPE); 111 if (!r) { 112 throw new FTPException(getReplyCode()); 113 } 114 } 115 116 117 126 public Socket openDataConnection(int command, String path) 127 throws IOException { 128 Socket socket = _openDataConnection_(command, path); 129 if (socket == null) { 130 throw new FTPException(this.getReplyCode()); 131 } 132 return socket; 133 } 134 135 136 } 137 | Popular Tags |