Http相关(以后再整理)

来源:互联网 发布:mac 大型网游 编辑:程序博客网 时间:2024/06/06 00:44
/*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);*/
0 0
原创粉丝点击