/*URL url = new URL("http://192.168.1.127:81/tmpfs/auto.jpg?1433329819419");
HttpURLConnection conn= (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5*1000);
conn.connect();
InputStream in=conn.getInputStream();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
byte[] buffer=new byte[1024 * 17];
int len = 0;
while((len=in.read(buffer))!=-1){
bos.write(buffer,0,len);
}
byte[] dataImage=bos.toByteArray();
bos.close();
in.close(); */
/*org.apache.http.client.HttpClient client2 = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://192.168.1.127:81/tmpfs/auto.jpg?1433329819419");
HttpResponse httpResponse = client2.execute(httpget);
int status2 = httpResponse.getStatusLine().getStatusCode();
if (status2 == HttpStatus.SC_OK) {
}
String strResult = EntityUtils.toString(httpResponse.getEntity());
byte[] b = Base64.decode(, Base64.NO_WRAP);*/
Http相关(以后再整理)
最新推荐文章于 2025-12-26 17:02:24 发布
本文详细介绍了如何通过HTTP协议发送GET请求,并从远程服务器下载图片的过程,包括创建URL、设置连接超时、发送请求、接收响应、解析数据等关键步骤。
176万+

被折叠的 条评论
为什么被折叠?



