From a user:
Hello,
I'm writing ftp client in JDK 1.5 and I have a problem, I'm getting these errors:
on upload:
FTP Error: vas.VASFileTransferException: Wystapil FTPException: com.enterprisedt
.net.ftp.FTPException: Illegal PORT command and FileTransferException on download, my code is here:
private void connect(String serverName, int portNumber)
throws FTPException, IOException{
this.ftpClient = new FTPClient(serverName, portNumber);
try{
ftpClient.login(logger.getLogin(),logger.getPassword());
}
catch(FTPException exc){
throw new FTPException("Blad autentykacji");
}
ftpClient.setType(FTPTransferType.BINARY);
ftpClient.setConnectMode(FTPConnectMode.ACTIVE);
ftpClient.setProgressMonitor(this.progressMonitor);
}
public void upload(File f, URL url)
throws VASFileTransferException{
String host=url.getHost();
int port=url.getPort();
File filePath=new File(url.getPath());
String directory=filePath.getParent().substring(1);
String filename=filePath.getName();
try{
connect(host, port);
ftpClient.chdir(directory);
ftpClient.put(new FileInputStream(f), filename);
disconnect();
}
catch(FTPException exc){
throw new vas.VASFileTransferException("Wystapil FTPException: "+exc);
}
catch(IOException exc){
throw new vas.VASFileTransferException("Wystapil IOException: "+exc);
}
}
public void download(URL url, File destination)
throws vas.VASFileTransferException{
String host=url.getHost();
int port=url.getPort();
File filePath=new File(url.getPath());
String directory=filePath.getParent().substring(1);
String filename=filePath.getName();
try{
connect(host, port);
ftpClient.chdir(directory);
ftpClient.get(new FileOutputStream(destination), filename);
disconnect();
}
catch(FTPException exc){
throw new vas.VASFileTransferException();
}
catch(IOException exc){
throw new vas.VASFileTransferException();
}
}
}
Have you got any suggestions? This error isn't show on JDK 1.4.2
[/code]