public Consumer downloadTo()

in src/main/java/org/apache/openejb/tools/release/cmd/Dist.java [305:322]


        public Consumer<URI> downloadTo(final File directory, final boolean overwrite) {
            return uri -> {
                try {
                    final String name = uri.getPath().replaceAll(".*/", "");
                    final File file = new File(directory, name);

                    if (file.exists() && !overwrite) {
                        out.println("Downloaded " + uri);
                    } else {
                        out.println("Downloading " + uri);
                        final CloseableHttpResponse response = get(uri);
                        IO.copy(response.getEntity().getContent(), file);
                    }
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            };
        }