hello world

在网上下载资源

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class downloadInternet {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://www.layui.com/demo/table/user/");
        url.openConnection();
        InputStream inputStream = url.openStream();
        FileOutputStream fos = new FileOutputStream("internetJson.txt");
        byte[] bytes = new byte[1024];
        int len;
        while ((len = inputStream.read(bytes)) != -1){
            fos.write(bytes,0,len);
        }
        inputStream.close();
        fos.close();
    }
}

 

posted @ 2021-09-23 15:30  SunsetRollercoaster  阅读(43)  评论(0)    收藏  举报