下载图片
public class URLTest {
public static void main(String[] args) throws IOException {
URL url = new URL("https://imgessl.kugou.com/stdmusic/20200909/20200909112317319417.jpg");
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream("ssss.jpg");
byte[] bytes = new byte[1024];
int len;
while ( (len = inputStream.read(bytes)) != -1){
fileOutputStream.write(bytes,0,len);
}
fileOutputStream.close();
inputStream.close();
}
}