title: Apache FTPClient - incomplete file retrieval on Linux, works on Windows
body: <p>I have a java application on Websphere that is using Apache Commons FTPClient to retrieve files from a Windows server via FTP.  When I deploy the application to Websphere running in a Windows environment, I am able to retrieve all of the files cleanly.  However, when I deploy the same application to Webpshere on Linux, there are cases where I am getting an incomplete or corrupt files.  These cases are consistent though, such that the same files will fail every time and give back the same number of bytes (usually just a few bytes less than what I should be getting).  I would say that I can read approximately 95% of the files successfully on Linux.</p>
  
  <p>Here's the relevant code...</p>
  
  <pre><code>ftpc = new FTPClient();
  // set the timeout to 30 seconds
      ftpc.enterLocalPassiveMode();
      ftpc.setDefaultTimeout(30000);
      ftpc.setDataTimeout(30000); 
      try
      {
                String ftpServer = CoreApplication.getProperty("ftp.server");
          String ftpUserID = CoreApplication.getProperty("ftp.userid");
          String ftpPassword = CoreApplication.getProperty("ftp.password");
  
          log.debug("attempting to connect to ftp server = "+ftpServer);
          log.debug("credentials = "+ftpUserID+"/"+ftpPassword);
  
          ftpc.connect(ftpServer);
  
          boolean login = ftpc.login(ftpUserID, ftpPassword);
  
          if (login) 
          {
              log.debug("Login success...");          } 
          else 
          {
              log.error("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);
              throw new Exception("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);
          }
  
          is = ftpc.retrieveFileStream(fileName);
            ByteArrayOutputStream out = null; 
            try { 
  
                out = new ByteArrayOutputStream(); 
                IOUtils.copy(is, out); 
            } finally { 
                IOUtils.closeQuietly(is); 
                IOUtils.closeQuietly(out); 
            }
  
            byte[] bytes = out.toByteArray();
            log.info("got bytes from input stream - byte[] size is "+ bytes.length);
  </code></pre>
  
  <p>Any assistance with this would be greatly appreciated. </p>
  
  <p>Thanks.</p>