All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.snyk.snyk_maven_plugin.download.FileDownloader Maven / Gradle / Ivy

Go to download

Tests and monitors your Maven dependencies for vulnerabilities. This plugin is officially maintained by Snyk.io

The newest version!
package io.snyk.snyk_maven_plugin.download;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public interface FileDownloader {
    void download(URL url, File target) throws IOException;

    static void downloadFile(URL url, File target) throws IOException {
        try (
            ReadableByteChannel rbc = Channels.newChannel(url.openStream());
            FileOutputStream fos = new FileOutputStream(target)
        ) {
            fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy