io.snyk.snyk_maven_plugin.download.FileDownloader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snyk-maven-plugin Show documentation
Show all versions of snyk-maven-plugin Show documentation
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);
}
}
}