Buongiorno a tutti,
sto cercando un modo per poter scaricare un file da una cartelle ftp per salvarlo in locale, e dopo averlo salvato eliminarlo dalla cartella ftp, tutto in modo automatico. Vi aggiungo il codice i come scarico il file:

codice:
import sun.net.ftp.FtpClient;

public void scaricaXml(String nomeMit, String ftp, String ftpUser, String ftpPsw){    
    try{
        String nomeFile=nomeMit+"_sito1.xml";
        FtpClient ftpClient = new FtpClient(ftp);
        ftpClient.login(ftpUser,ftpPsw);
        ftpClient.binary();
          
        InputStream is = ftpClient.get(nomeFile);
        BufferedInputStream bis = new BufferedInputStream(is);
        OutputStream os = new FileOutputStream("path"+nomeFile);
        BufferedOutputStream bos = new BufferedOutputStream(os);
        byte [] buffer = new byte[16264];
        int readCount;
        while( (readCount = bis.read(buffer)) > 0){
           bos.write(buffer, 0, readCount);
        }

        bos.close();
        
        ftpClient.closeServer();
   }
   catch(IOException ioe){
     System.out.println("Errore:"+ioe.getLocalizedMessage());
   }
    
    }
se qualcuno ha qualche idea..
grazie mille in anticipo