Source:
private void writeClosedAccountsToCsvFile(List<ClosedAccount> closedAccountsDataList) throws IOException { String csvFileName = generateCsvOutputFileName(); String fullyQualifiedCreationDirectoryFileName = fullyQualifyFileNameToCreationDirectory(csvFileName); LOG.info("writeClosedAccountsToCsvFile: fullyQualifiedOutputFile = " + fullyQualifiedCreationDirectoryFileName); File outputFile = new File(fullyQualifiedCreationDirectoryFileName); FileWriter outputFileWriter; try { outputFileWriter = new FileWriter(outputFile); for (ClosedAccount closedAccount : closedAccountsDataList) { outputFileWriter.write(closedAccount.toCsvString()); outputFileWriter.write(KFSConstants.NEWLINE); } outputFileWriter.flush(); outputFileWriter.close(); LOG.info("writeClosedAccountsToCsvFile: CSV file in being-written directory has all the data and file has been closed."); } catch (IOException io) { LOG.error("writeClosedAccountsToCsvFile: Caught IOException attempting to create CSV file of closded accounts => ", io); throw io; } try { String fullyQualifiedExportDirectoryFileName = fullyQualifyFileNameToExportDirectory(csvFileName); LOG.info("writeClosedAccountsToCsvFile: Moving data file from creation directory to fullyQualifiedExportDirectoryFileName = " + fullyQualifiedExportDirectoryFileName); moveCreatedFileToExportDirectory(outputFile, fullyQualifiedExportDirectoryFileName); LOG.info("writeClosedAccountsToCsvFile: File was successfully moved to export directory."); } catch (IOException io2) { LOG.error("writeClosedAccountsToCsvFile: Caught IOException attempting to move CSV file of closed accounts to export directory => ", io2); throw io2; } }

Target:
private void writeClosedAccountsToCsvFile(List<ClosedAccount> closedAccountsDataList) throws IOException { String csvFileName = generateCsvOutputFileName(); String fullyQualifiedCreationDirectoryFileName = fullyQualifyFileNameToCreationDirectory(csvFileName); LOG.info("writeClosedAccountsToCsvFile: fullyQualifiedOutputFile = " + fullyQualifiedCreationDirectoryFileName); File outputFile = new File(fullyQualifiedCreationDirectoryFileName); FileWriter outputFileWriter; outputFileWriter = new FileWriter(outputFile); try { for (ClosedAccount closedAccount : closedAccountsDataList) { outputFileWriter.write(closedAccount.toCsvString()); outputFileWriter.write(KFSConstants.NEWLINE); } outputFileWriter.flush(); LOG.info("writeClosedAccountsToCsvFile: CSV file in being-written directory has all the data, was flushed, and file will attempt to now be closed."); } catch (IOException io) { LOG.error("writeClosedAccountsToCsvFile: Caught IOException attempting to create CSV file of closded accounts => ", io); throw io; } finally { IOUtils.closeQuietly(outputFileWriter); } try { String fullyQualifiedExportDirectoryFileName = fullyQualifyFileNameToExportDirectory(csvFileName); LOG.info("writeClosedAccountsToCsvFile: Moving data file from creation directory to fullyQualifiedExportDirectoryFileName = " + fullyQualifiedExportDirectoryFileName); moveCreatedFileToExportDirectory(outputFile, fullyQualifiedExportDirectoryFileName); LOG.info("writeClosedAccountsToCsvFile: File was successfully moved to export directory."); } catch (IOException io2) { LOG.error("writeClosedAccountsToCsvFile: Caught IOException attempting to move CSV file of closed accounts to export directory => ", io2); throw io2; } }