Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you check the return status of any of the calls or is that the code? </p> <p>There is a call completePendingCommand() that has to be used on occassion. That may be something to look into. </p> <p>Also, you won't see an IO exception, I belive it gets repackaged as a CopyStreamException</p> <p>You might want to also change the return value to a boolean since you trap the exceptions, at least the calling loop will know whether the tranfer happened or not. </p> <p></p> <pre><code>private boolean loadFTPFile(String host, String username, String password, String filename, String localFilename){ System.out.println(localFilename); FTPClient client = new FTPClient(); FileOutputStream fos = null; try { client.connect(host); int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)){ client.disconnect(); System.err.println("FTP server refused connection."); return false; } if (!client.login(username, password)){ client.logout(); return false; } String localFilenameOutput = createFile(assetsPath + localFilename); fos = new FileOutputStream(localFilenameOutput); boolean result = client.retrieveFile(filename, fos); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); if (result){ System.out.println("\tFile Transfer Completed Successfully at: " + sdf.format(Calendar.getInstance().getTime())); // ftp.completePendingCommand(); } else { System.out.println("\tFile Transfer Failed at: " + sdf.format(Calendar.getInstance().getTime())); } return result; }catch (CopyStreamException cse){ System.err.println("\n\tFile Transfer Failed at: " + sdf.format(Calendar.getInstance().getTime())); System.err.println("Error Occurred Retrieving File from Remote System, aborting...\n"); cse.printStackTrace(System.err); System.err.println("\n\nIOException Stack Trace that Caused the Error:\n"); cse.getIOException().printStackTrace(System.err); return false; }catch (Exception e){ System.err.println("\tFile Transfer Failed at: " + sdf.format(Calendar.getInstance().getTime())); System.out.println("Error Occurred Retrieving File from Remote System, aborting..."); e.printStackTrace(System.err); return false; } finally { try { if (fos != null) fos.close(); client.disconnect(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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