yes there is a loop(thread) but later, after login and changing/creating dirs
this is the last version wih getLastValidReply()
as i said i also tried with login(user,password)
what about following scenario:
the login is done, and then the server closes the connection and ftpj is sending pasv
without knowing that the connection is closed because the server sends a wrong or none message?
and then , yes there must be a loop, as printed in debug
public void ????() {
try {
ftp = new FTPClient();
ftp.setMessageListener(new MyMessageListener());
ftp.setProgressMonitor(this);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setRemoteHost(Properties.IP_ADRESS);
ftp.connect();
if (ftp.connected()) {
ftp.user(Properties.FTP_USER);
if (ftp.getLastValidReply().getReplyCode().equals("331")) {
ftp.password(Properties.FTP_PASSWORD);
}
}
// when the error occurs it doesn't come to this part / commands
// as printed in the debug log
ftp.chdir("html/fileadmin/shootings/");
boolean customerDirExists = false;
String[] filenames = ftp.dir();
for (int i = 0; i < filenames.length; i++) {
if (filenames[i].equals(ftpCustomerDirName)) {
customerDirExists = true;
break;
}
}
if (customerDirExists == false) {
ftp.mkdir(ftpCustomerDirName);
}
ftp.chdir(ftpCustomerDirName);
if (!isZipUpload) {
try {
ftp.mkdir(folderName);
folderPath = Properties.dirPrefix + ftpCustomerDirName
+ "/" + folderName;
} catch (FTPException fe) {
JOptionPane.showMessageDialog(myDesktop,
"Dieser Shooting Ordner existiert schon.");
ftp.quit();
dispose();
}
ftp.chdir(folderName);
}
ftp.setType(FTPTransferType.BINARY);
} catch (IOException e) {
e.printStackTrace();
} catch (FTPException fe) {
fe.printStackTrace();
}
Thread upl = new Thread(this);
upl.start();
}
public void run() {
int count = 0;
while (count < picsToUpload.length) {
try {
ftp.put(picsToUpload[count].getAbsolutePath(),
picsToUpload[count].getName());
count++;
} catch (IOException ioe) {
System.out.println("ioe-error");
} catch (FTPException fe) {
System.out.println("error");
}
}
cleanup();
}