Source:
<code>public void run() { FTPClient ftp = new FTPClient(); String remoteTempFilename = null; OutputStream out = null; try { int reply; ftp.connect(configration.getUrl(), configration.getPort()); ftp.login(configration.getUsername(), configration.getPassword()); reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); LOG.error("FTPReply is " + reply + ", disconnected."); return; } ftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); if(!ftp.changeWorkingDirectory("/")) { throw new IOException("Can not change to " + configration.getRootDir()); } String remoteDir = mgr.getParentPath(configration.getRootDir(), ident); <START> ftpCreateDirectoryTree(ftp, remoteDir); <END> LOG.debug("Current FTP working directory is: " + ftp.printWorkingDirectory()); String remoteFilename = mgr.getCompressedFileName(ident); remoteTempFilename = remoteFilename + ".tmp"; out = new GZIPOutputStream(ftp.storeFileStream(remoteTempFilename)); remoteWrite(out); if (!ftp.completePendingCommand()) { throw new IOException("Unfinished upload."); } if(!ftp.rename(remoteTempFilename, remoteFilename)) { throw new IOException("Unfinished rename."); } LOG.debug(remoteFilename + " uploaded."); ftp.logout(); } catch (IOException e) { LOG.error("Oops, got an excepion.", e); if (ftp.isConnected() && remoteTempFilename != null) { try { ftp.deleteFile(remoteTempFilename); } catch (IOException e1) { } } } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException e) { } } } }</code><technical_language>happen if remotedir exist</technical_language>

Target:
public void run() { FTPClient ftp = new FTPClient(); String remoteTempFilename = null; OutputStream out = null; try { int reply; ftp.connect(configration.getUrl(), configration.getPort()); ftp.login(configration.getUsername(), configration.getPassword()); reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); LOG.error("FTPReply is " + reply + ", disconnected."); return; } ftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); if(!ftp.changeWorkingDirectory("/")) { throw new IOException("Can not change to " + configration.getRootDir()); } String remoteDir = mgr.getParentPath(configration.getRootDir(), ident); ftpCreateDirectoryTree(ftp, remoteDir); LOG.debug("Current FTP working directory is: " + ftp.printWorkingDirectory()); String remoteFilename = mgr.getCompressedFileName(ident); remoteTempFilename = "." + remoteFilename + ".tmp"; out = new GZIPOutputStream(ftp.storeFileStream(remoteTempFilename)); remoteWrite(out); if (!ftp.completePendingCommand()) { throw new IOException("Unfinished upload " + remoteFilename); } if(!ftp.rename(remoteTempFilename, remoteFilename)) { throw new IOException("Unfinished rename to " + remoteFilename); } LOG.info(remoteFilename + " uploaded."); ftp.logout(); } catch (IOException e) { LOG.error("Oops, got an excepion.", e); if (ftp.isConnected() && remoteTempFilename != null) { try { ftp.deleteFile(remoteTempFilename); } catch (IOException e1) { } } } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException e) { } } } }