标签:create size mil file 下载 imp out cep nts
Http02App.java
1.使用两个工具类 实现下载音乐和图片到本地硬盘中
package main;
import Http.FileUtils;
import Http.HttpUtils;
import java.io.IOException;
/**
* Created by lxj-pc on 2017/6/27.
*/
public class Http02App {
static String imgurl = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
static String mp3url = "http://static.iyuba.com/sounds/voa/201706/5172.mp3";
public static void main(String[] args) {
//下载图片
new Thread() {
public void run() {
byte[] bytes = new byte[0];
try {
bytes = HttpUtils.get(imgurl);
} catch (IOException e) {
e.printStackTrace();
}
//将下载完成的图片保存到本地
//
try {
FileUtils.saveImg(bytes,"d:/lxj/picture",
System.currentTimeMillis()+".jpg");
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("图片下载保存到本地ok!");
}
}.start();
}
}
标签:create size mil file 下载 imp out cep nts
原文地址:http://www.cnblogs.com/lxj666/p/7087456.html