importsun.net.ftp.FtpClient;importjava.net.Socket;importjava.io.IOException;publicclassPasvFtpClientextendsFtpClient{/*** FTP服务器的地址*/privateString serverAddr;/*** 连接到FTP服务器的Socket*/privateSocket socket;/*** 仿造父类定义的静态变量*/protectedfinalstaticintFTP_ERROR=3;/*** 仿造父类定义的静态变量*/protectedfinalstaticintFTP_SUCCESS=1;publicPasvFtpClient(String s)throwsIOException{super(s);
serverAddr=s;
socket=null;
}publicPasvFtpClient(String s,inti)throwsIOException{super(s,i);
serverAddr=s;
socket=null;
}publicPasvFtpClient(){super();
socket=null;
}/*** 复写的主要部分,父类采用PORT模式,这里改为PASV模式
*@params 传入的FTP命令
*@return连接到FTP服务器的Socket
*@throwsIOException*/protectedSocket openDataConnection(String s)throwsIOException{if(socket==null){
String s1="PASV";if(issueCommand(s1)==FTP_ERROR){