文章目录
普通程序员
commons-httpclient-3.0-src.zip下载
用Eclipse新建一个kotlin项目,同时新建一个libs文件夹,把jar包放入
然后右键jar包-Build Path-Add to Build Path
按照官方文档的写法我们写一个下载图片的代码
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.methods.GetMethod
import java.io.File
fun main(args: Array<String>) {
//创建一个httpclient
var client = HttpClient()
var method = GetMethod("http://xx.jpg");
client.executeMethod(method)
var responseBody = method.getResponseBody();
method.releaseConnection();
var file = File("1.jpg")
file.<