找到一个可以在网页播放的音乐,开始播放
右键页面选择检查元素,或者按F12键
根据图片中的步骤找到音乐的URL地址,并复制
public class UrlDown {
public static void main(String[] args) throws Exception {
//1、下载地址
URL url = new URL("网址覆盖到这里");
//2、连接到这个资源HTTP
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
//3、写出这个数据
InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fos = new FileOutputStream("f0b46c.m4a");//格式要保持一致
byte[] bys = new byte[1024];
int len;
while((len=inputStream.read(bys))!=-1){
fos.write(bys,0,len);
}
//4、断开连接
fos.close();
inputStream.close();
urlConnection.disconnect();
}
}
原文:https://www.cnblogs.com/ithpower/p/13280032.html