http下载图片
模擬http請(qǐng)求下載網(wǎng)絡(luò)圖片:
要導(dǎo)入commons-httpclient-3.1.jar包。
package com.base.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
public class DownloadPic {
/**
* @param args
* @throws IOException?
* @throws HttpException?
*/
public static void main(String[] args) throws HttpException, IOException {
// TODO Auto-generated method stub
HttpClient client=new HttpClient();
GetMethod get=new GetMethod("http://kf.bsoft.com.cn:81/upload/Requirement/05999/059990163613/201410101400428761.jpg");
client.executeMethod(get);
File storeFile=new File("d:/hehe.jpg");
FileOutputStream s=new FileOutputStream(storeFile);
s.write(get.getResponseBody());
s.close();
}
}
總結(jié)
- 上一篇: http上传图片
- 下一篇: pl/sql链接64位oracle数据库