Source:
<code>private File downloadToLocalRepository(final String relativeRemotePath, final String remoteFileName, final File parentDir) throws FileNotFoundException { assert relativeRemotePath != null; assert remoteFileName != null; assert parentDir != null; final URL relativePathURL; final URL fullURL; try { relativePathURL = new URL(rootUrl, relativeRemotePath); fullURL = new URL(relativePathURL, remoteFileName); } catch (final MalformedURLException murle) { throw new RuntimeException(murle); } final File targetFile = new File(parentDir, remoteFileName); final InputStream in; try { if (log.isLoggable(Level.INFO)) { log.info("Writing: " + fullURL + " as " + targetFile); } in = fullURL.openStream(); } catch (final IOException ioe) { throw new RuntimeException("Could not get stream to " + fullURL.toExternalForm(), ioe); } if (in == null) { throw new FileNotFoundException("Could not find requested file at URL: " + fullURL.toExternalForm()); } if (!parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create parent directory: " + parentDir); } OutputStream out = null; try { try { out = new FileOutputStream(targetFile); } catch (final FileNotFoundException fnfe) { throw new RuntimeException(fnfe); } final byte[] buffer = new byte[512]; try { int readBytes = 0; while ((readBytes = in.read(buffer)) != -1) { out.write(buffer, 0, readBytes); if (log.isLoggable(Level.INFO)) { System.out.print('.'); } } if (log.isLoggable(Level.INFO)) { System.out.println(); } } catch (final IOException ioe) { throw new RuntimeException(ioe); } } finally { try { if (out != null) { out.close(); if (log.isLoggable(Level.INFO)) { log.info("Wrote " + targetFile.getAbsolutePath()); } <START> } <END> } catch (final IOException ioe) { } } return targetFile; }</code><technical_language>out is closed in</technical_language>

Target:
private File downloadToLocalRepository(final String relativeRemotePath, final String remoteFileName, final File parentDir) throws FileNotFoundException { assert relativeRemotePath != null; assert remoteFileName != null; assert parentDir != null; final URL relativePathURL; final URL fullURL; try { relativePathURL = new URL(rootUrl, relativeRemotePath); fullURL = new URL(relativePathURL, remoteFileName); } catch (final MalformedURLException murle) { throw new RuntimeException(murle); } final File targetFile = new File(parentDir, remoteFileName); final InputStream in; try { if (log.isLoggable(Level.INFO)) { log.info("Writing: " + fullURL + " as " + targetFile); } in = fullURL.openStream(); } catch (final IOException ioe) { throw new RuntimeException("Could not get stream to " + fullURL.toExternalForm(), ioe); } if (in == null) { throw new FileNotFoundException("Could not find requested file at URL: " + fullURL.toExternalForm()); } if (!parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create parent directory: " + parentDir); } OutputStream out = null; try { try { out = new FileOutputStream(targetFile); } catch (final FileNotFoundException fnfe) { throw new RuntimeException(fnfe); } final byte[] buffer = new byte[512]; try { int readBytes = 0; while ((readBytes = in.read(buffer)) != -1) { out.write(buffer, 0, readBytes); if (log.isLoggable(Level.INFO)) { System.out.print('.'); } } if (log.isLoggable(Level.INFO)) { System.out.println(); } } catch (final IOException ioe) { throw new RuntimeException(ioe); } } finally { if (in != null) { try { in.close(); } catch (final IOException ignore) { } } try { if (out != null) { out.close(); if (log.isLoggable(Level.INFO)) { log.info("Wrote " + targetFile.getAbsolutePath()); } } } catch (final IOException ioe) { } } return targetFile; }