Source:
private static void upload(String ftpHost, int port, String user, String password, InputStream is, String fileName) { LOGGER.debug("FTP host to upload data : " + ftpHost); LOGGER.debug("FTP port to upload data : " + port); LOGGER.debug("Destination file name : " + fileName); long start = System.currentTimeMillis(); FTPClient ftp = new FTPClient(); try { int reply; ftp.connect(ftpHost, port); LOGGER.debug("Connected to server : " + ftpHost); reply = ftp.getReplyCode(); LOGGER.debug("Reply code is : " + reply); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); LOGGER.info("FTP server refused connection. Reply code is : " + reply); throw new Exception("FTP server refused connection."); } if (!ftp.login(user, password)) { throw new Exception("Login to ftp failed. Check user credentials."); }; LOGGER.debug("User has been successfully logged in."); ftp.setFileType(FTP.BINARY_FILE_TYPE); try { ftp.enterRemotePassiveMode(); LOGGER.debug("Passive host : " + ftp.getPassiveHost() + " Passive port : " + ftp.getPassivePort()); LOGGER.debug("Default port : " + ftp.getDefaultPort()); LOGGER.debug("Local port : " + ftp.getLocalPort()); LOGGER.debug("Remote port : " + ftp.getRemotePort()); if (ftp.storeFile(fileName, is)) { long finish = System.currentTimeMillis(); LOGGER.info("Video uploading completed in " + (finish - start) + " msecs."); } else { LOGGER.info("Some issues occures during storing file to FTP. storeFile method returns false."); } } catch (IOException e) { LOGGER.info("Exception while storing file to FTP", e); } } catch (Exception e) { LOGGER.info("Exception while uploading while to FTP", e); } finally { ftpDisconnect(ftp); } }

Target:
private static void upload(String ftpHost, int port, String user, String password, InputStream is, String fileName) { LOGGER.debug("FTP host to upload data : " + ftpHost); LOGGER.debug("FTP port to upload data : " + port); LOGGER.debug("Destination file name : " + fileName); long start = System.currentTimeMillis(); FTPClient ftp = new FTPClient(); try { int reply; ftp.connect(ftpHost, port); LOGGER.debug("Connected to server : " + ftpHost); reply = ftp.getReplyCode(); LOGGER.debug("Reply code is : " + reply); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); LOGGER.info("FTP server refused connection. Reply code is : " + reply); throw new Exception("FTP server refused connection."); } if (!ftp.login(user, password)) { throw new Exception("Login to ftp failed. Check user credentials."); }; LOGGER.debug("User has been successfully logged in."); ftp.setFileType(FTP.BINARY_FILE_TYPE); try { ftp.enterLocalPassiveMode(); LOGGER.debug("Passive host : " + ftp.getPassiveHost() + " Passive port : " + ftp.getPassivePort()); LOGGER.debug("Default port : " + ftp.getDefaultPort()); LOGGER.debug("Local port : " + ftp.getLocalPort()); LOGGER.debug("Remote port : " + ftp.getRemotePort()); if (ftp.storeFile(fileName, is)) { long finish = System.currentTimeMillis(); LOGGER.info("Video uploading completed in " + (finish - start) + " msecs."); } else { LOGGER.info("Some issues occures during storing file to FTP. storeFile method returns false."); } } catch (IOException e) { LOGGER.info("Exception while storing file to FTP", e); } } catch (Exception e) { LOGGER.info("Exception while uploading while to FTP", e); } finally { ftpDisconnect(ftp); } }