少年阿賓

          那些青春的歲月

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

          常用鏈接

          留言簿(22)

          我參與的團(tuán)隊(duì)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          package com.abin.lii.han.limei;

          import java.io.BufferedReader;
          import java.io.InputStreamReader;
          import java.net.HttpURLConnection;
          import java.net.URL;

          import org.junit.Test;

          public class ImediaRegisterTest {
           @Test
           public void testImediaRegister(){
            String LIMEI_HTTP="  String appId="fk000";
            String udid="3A5S4D6F8G9K_3596140444464123";
            String requestUrl=LIMEI_HTTP+"?app="+appId+"&udid="+udid+"&source="+"where"";
            System.out.println(requestUrl);
            String result="";
            try {
             URL url=new URL(requestUrl);
             HttpURLConnection connection=(HttpURLConnection)url.openConnection();
             connection.setDoOutput(true);
             connection.setDoInput(true);
             connection.setRequestMethod("GET");
             connection.setUseCaches(false);
             // URLConnection.setInstanceFollowRedirects是成員函數(shù),僅作用于當(dāng)前函數(shù)
             connection.setInstanceFollowRedirects(false);
             connection.setRequestProperty("Content-Type",
                          "application/x-www-form-urlencoded");
             connection.connect();
             //發(fā)送執(zhí)行請(qǐng)求
             
             //接收返回請(qǐng)求
             BufferedReader reader=new BufferedReader(new InputStreamReader(connection.getInputStream(),"GBK"));
             String line="";
             StringBuffer buffer=new StringBuffer();
             while((line=reader.readLine())!=null){
              buffer.append(line);
             }
             result=buffer.toString();
             System.out.println("result="+result);
             connection.disconnect();
            } catch (Exception e) {
             e.printStackTrace();
            }
           }

          }

          Feedback

          # re: HttpUrlConnection GET 2016-08-03 16:03 殺毒
          是  回復(fù)  更多評(píng)論
            


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 佳木斯市| 甘孜| 禹城市| 平安县| 都昌县| 河南省| 新乡市| 焦作市| 辽宁省| 阜宁县| 淅川县| 瑞金市| 博野县| 佛坪县| 衡山县| 宜兴市| 青神县| 长治市| 高唐县| 札达县| 盘山县| 辰溪县| 西畴县| 林芝县| 宣武区| 抚远县| 芒康县| 琼结县| 腾冲县| 云浮市| 年辖:市辖区| 通榆县| 镇江市| 元氏县| 武威市| 云梦县| 磐安县| 玛多县| 孟州市| 昔阳县| 大邑县|