Java Utililty Methods URL Download nio

List of utility methods to do URL Download nio

Description

The list of methods to do URL Download nio are organized into topic(s).

Method

booleancanDownload(String filePath)
can Download
try {
    if (new File(filePath).exists()) {
        Files.delete(Paths.get(filePath));
    return true;
} catch (IOException ignored) {
    return false;
booleandownload(File dist, URL src)
download
InputStream is = null;
ReadableByteChannel in = null;
FileOutputStream fos = null;
FileChannel out = null;
try {
    URLConnection connection = src.openConnection();
    is = connection.getInputStream();
    in = Channels.newChannel(is);
...
voiddownload(String from, String to)
download
download(newURL(from), Paths.get(to));
booleandownload(String link, File destFile)
download
return download(link, destFile, false);
voiddownload(String url, File output)
download
URL url1 = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(url1.openStream());
FileOutputStream fos = new FileOutputStream(output);
if (!output.exists()) {
    output.getParentFile().mkdirs();
    output.createNewFile();
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
...
voiddownload(String url, String destPath)
download
InputStream downloadIn = new BufferedInputStream(new URL(url).openStream(), BUFFER);
File destFile = new File(destPath);
com.google.common.io.Files.createParentDirs(destFile);
Files.copy(downloadIn, destFile.toPath());
Pathdownload(String url, String inputFile, String outputPath, String outputFile)
download
return download(url + inputFile, outputPath, outputFile);
voiddownload(URI source, File target)

Downloads a file from the Internet

ReadableByteChannel rbc = Channels.newChannel(source.toURL().openStream());
FileOutputStream fos = new FileOutputStream(target, false);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
voiddownload(URL link, File outputFile)
Download a file from a specific url.
if (link == null)
    throw new IllegalArgumentException("dl link cannot be null");
ReadableByteChannel rbc = Channels.newChannel(link.openStream());
FileOutputStream output = new FileOutputStream(outputFile);
output.getChannel().transferFrom(rbc, 0, 1 << 24);
output.close();
voiddownload(URL url, File out)
download
File parent = out.getParentFile();
if (!out.exists()) {
    if (parent != null)
        parent.mkdirs();
    File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".tmp", parent);
    tempFile.deleteOnExit();
    try (InputStream is = url.openStream()) {
        ReadableByteChannel rbc = Channels.newChannel(is);
...