Java URL Download download(String url, String path)

Here you can find the source of download(String url, String path)

Description

download

License

Open Source License

Declaration

public static void download(String url, String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileOutputStream;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

public class Main {

    public static void download(String url, String path) {
        InputStream is = null;/*  w w w  . jav a2 s  . co  m*/
        OutputStream os = null;
        try {
            is = new URL(url).openStream();
            byte[] bs = new byte[1024];
            int len;
            os = new FileOutputStream(path);
            while ((len = is.read(bs)) != -1) {
                os.write(bs, 0, len);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
                os.close();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

Related

  1. download(final String sURL, final String sFilename)
  2. download(final URL url)
  3. download(String downloadUrlStr, String filename)
  4. download(String fileUrl, String savePath, String fileName)
  5. download(String url)
  6. download(String url, String saveFile)
  7. download(String url, String toFile)
  8. download(String urlAddress, File file)
  9. download(String urlString)