package Url;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.URL;
public class Down {
public static void main(String[] args) throws IOException {
//协议://IP地址,端口/具体内容
URL url=new URL("https://m801.music.126.net/20231211141643/9d7479c25a801b223eae1f6c5aa0f149/jdyyaac/obj/w5rDlsOJwrLDjj7CmsOj/32016181849/c4dc/f9de/d083/884c97633d30deee4077d94d27c73a01.m4a");
//链接资源
HttpsURLConnection httpsUrl = (HttpsURLConnection) url.openConnection();
//读取
InputStream in=httpsUrl.getInputStream();
//写出
FileOutputStream be=new FileOutputStream("E:/IT/a.m4a");
byte[] line=new byte[1024];
int len;
while ((len=in.read(line)) !=-1){
be.write(line,0,len);
}
//关闭
httpsUrl.disconnect();
in.close();
be.close();
}
}
URL输出
最新推荐文章于 2024-10-12 22:35:37 发布