Note that there are some explanatory texts on larger screens.

plurals
  1. POJava FTP file get issue
    text
    copied!<p>I have a application that runs as a schedule.It connect to ftp server and get files from remote folder.scheduler runs in every 5min time.Sometimes when there are lot of files in remote location, scheduler runs again while first cycle is running.In such situation some times it download 0 size files even actual file size is greater than 0 in remote location.Does anyone have any idea why this happen?</p> <p>below is the code to import files.</p> <pre><code>private void importEDIFiles(String host, String user, String password, String path, String road) { try { String edi824Path = path + "/" + EDI_824_FOLDER; FTPBroker ftpBroker = new FTPBroker(host, user, password, edi824Path); FTPClient client = ftpBroker.makeFTPConeection(); String os = client.getSystemName(); client.setFileTransferMode(FTP.ASCII_FILE_TYPE); File edi824File = null; File edi824Filebak = null; ArrayList&lt;FTPFile&gt; files; try { FTPFile[] ftpfiles = client.listFiles(); logger.info("\t" + ftpfiles.length + " files are in ftp location "); if (ftpfiles.length &gt; 0) { files = removeZeroFiles(ftpfiles); for(int x=0;x&lt;files.size();x++){ logger.info("name ---"+files.get(x).getName()); logger.info("size ----"+files.get(x).getSize()); } String ftpFile = null; logger.info("\t" + files.size() + " downloading from " + road + " rail road."); for (int i = 0; i &lt; files.size(); i++) { ftpFile = files.get(i).getName(); logger.info("\t" + ftpFile + " is downloading...."); // logger.info("\t" + ftpFile + " size ...." + ftpFile.isEmpty()); String source = destinationFilePath + pathSeparator + road + pathSeparator + ftpFile; String target = edi_824backupFilePath + pathSeparator + road + pathSeparator + ftpFile; edi824File = new File(source); edi824Filebak = new File(target); FileOutputStream fosout = new FileOutputStream(source); boolean isRetrieved = client.retrieveFile(ftpFile, fosout); logger.debug("isRetrieved : " + isRetrieved); FileUtils.copyFile(edi824File,edi824Filebak); fosout.flush(); fosout.close(); boolean isDelete = client.deleteFile(ftpFile); logger.debug("isDelete : " + isDelete); } } else { logger.info("No files to Pull in the FTP Location for " + user); //throw new RuntimeException("No files to Pull in FTP Location."); } } catch (Exception e) { logger.error(e,e); e.printStackTrace(); } finally { client.logout(); client.disconnect(); } } catch (Exception ex) { logger.error(ex, ex); ex.printStackTrace(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload