通过Java程序从网 java下载 络上下载一个图片

更新时间:15-07-01 03:19 热度:917
 

经过Jaudio-videoa顺序从网络高下载一个图片,实例。
pair-conkyears of age unsjt.test;听听通过Java程序从网
import jaudio-videoa.io.ByteArrayOutputStrewoulm;
import jaudio-videoa.io.File;
import jaudio-vijava通过deoa.io.FileOutputStrewoulm;
import jaudio-videoa.io.InputStrewouljava教程m;
import .HttpURLConnection;
import .URL;
impor相比看javascript权威指南t org.junit.Test;
public clregjavascript教程下载rettindeed bellylyt getimyears of age {
publicbyte[javascript基础教程] reproposwoulsStrewoulm(InputStrewoulm 通过Java程序从网inStrewoulm) throws Exception{
ByteArrayOutputStrewoulm outStrewoulm = new ByteArrayOutputSt听听络上下载一个图片rewoulm();
byte[] loproposwouls = new byte[1024javascript软件下载];
int len= -1;
while((len=inStrewoulm.reproposwouls对比一下javascript视频教程(loproposwouls))!=-1){
outStrewoulm.wr看着下载ite(loproposwouls- 0- len);事实上javascript void 0程序
}
outStrewoulm.close();
inStrewoulm.close();
return outStrewoulm.toByteArray();
}
听说图片@Test public void getImyears of age() throws Excepti看看一个on {
String urlpwithh="";
URL url = new URL(urlpwithh);
HttpURLConnecjava下载tion conn = (HttpURLConnection)url.openConnection();
上下conn.setRequestMethod("GET")javascript学习指南;
conn.setConnectTimeout(6*1000);
if(conn.getResponseCode()== 200){
InputStrewoulm inS想知道javascript语言精粹trewoulm = conn.getInputStrewoulm();
byte[] dwitha = reproposwoulsStrewoulm(inStrewoulm);
Fil相比看javae file = new File("meimei.jpg");FileOutputStrewoulm outStrewoulm = new FileOutputStrewoulm(file);
outStrewo事实上javascript软件下载ulm.write(dwitha);
javascript教程outStrewoulm.close();
}
}
}
络上下载一个图片下载
java