package com.kuang.demo04;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class URLDemo01 {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://www.baidu.com/img/baidu_85beaf5496f291521eb75ba38eacbd87.svg");
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

        InputStream in = urlConnection.getInputStream();
        FileOutputStream Fout = new FileOutputStream("1.svg");

        byte[] buff = new byte[1024];
        int len;
        while ((len = in.read(buff)) != -1) {
            Fout.write(buff, 0, len);
        }

        Fout.close();
        in.close();
        urlConnection.disconnect();
    }
}
```java
在这里插入代码片