少年阿賓

          那些青春的歲月

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

          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è)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 葵青区| 阳朔县| 高安市| 南乐县| 牙克石市| 白山市| 华宁县| 育儿| 光泽县| 汉寿县| 和田县| 和田市| 磐石市| 扎鲁特旗| 德州市| 蒙阴县| 会昌县| 朝阳县| 正镶白旗| 准格尔旗| 丽水市| 高雄市| 会泽县| 古田县| 宁武县| 都兰县| 资溪县| 塘沽区| 牟定县| 绍兴市| 溧阳市| 南丹县| 漳浦县| 贞丰县| 图们市| 乳山市| 武胜县| 达日县| 山东| 清原| 右玉县|