<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

    Java HTTPS Client FAQ: Can you share some source code for a Java HTTPS client application?

    Sure, here's the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL. I actually found some of this in a newsgroup a while ago, but I can't find the source today to give them credit, so my apologies for that.

    I just used this program to troubleshoot a problem with Java and HTTPS URLs, including all that nice Java SSL keystore and cacerts stuff you may run into when working with Java, HTTPS/SSL, and hitting a URL.

    This Java program should work if you are hitting an HTTPS URL that has a valid SSL certificate from someone like Verisign or Thawte, but will not work with other SSL certificates unless you go down the Java keystore road.

    Example Java HTTPS client program

    Here's the source code for my simple Java HTTPS client program:




    package foo;

    import java.net.URL;
    import java.io.*;
    import javax.net.ssl.HttpsURLConnection;

    public class JavaHttpsExample
    {
      public static void main(String[] args)
      throws Exception
      {
        String httpsURL = "https://your.https.url.here/";
        URL myurl = new URL(httpsURL);
        HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
        InputStream ins = con.getInputStream();
        InputStreamReader isr = new InputStreamReader(ins);
        BufferedReader in = new BufferedReader(isr);

        String inputLine;

        while ((inputLine = in.readLine()) != null)
        {
          System.out.println(inputLine);
        }

        in.close();
      }
    }






    Just change the URL shown there to the HTTPS URL you want to access, and hopefully everything will work well for you. (If not, there's always that Comment section down below, lol.)




    http://www.devdaily.com/blog/post/java/simple-https-example
    posted on 2012-08-16 00:41 abin 閱讀(758) 評論(0)  編輯  收藏 所屬分類: httpClient
    主站蜘蛛池模板: 我要看WWW免费看插插视频| 久久亚洲中文字幕精品有坂深雪 | 免费无码又爽又刺激高潮视频| 亚洲欧洲专线一区| 亚洲黄色在线电影| 亚洲欧洲日产国码无码网站| 国产大片51精品免费观看| 最近的中文字幕大全免费8| 国产V片在线播放免费无码| 亚洲国产精品无码中文lv| 亚洲电影在线免费观看| 亚洲国产婷婷六月丁香| 亚洲欧洲久久久精品| 日韩a级毛片免费观看| 久久久久久99av无码免费网站| 在线涩涩免费观看国产精品 | 一本色道久久88亚洲综合| 毛片免费在线观看网站| 精品香蕉在线观看免费| 99ee6热久久免费精品6| 华人在线精品免费观看| 成人av片无码免费天天看| 一个人看的www视频免费在线观看 一个人看的免费观看日本视频www | 两个人看的www免费| 国产高清视频免费在线观看| 免费一级全黄少妇性色生活片 | 又大又黄又粗又爽的免费视频| 女人让男人免费桶爽30分钟| 99久久国产热无码精品免费| 1000部羞羞禁止免费观看视频| 久久免费福利视频| 99蜜桃在线观看免费视频网站| 无码人妻丰满熟妇区免费| 久久青草精品38国产免费| 免费观看男人吊女人视频| 国产成人免费ā片在线观看老同学| 一级特黄录像免费播放肥| 国产在线国偷精品免费看| 亚洲精品成a人在线观看夫| 亚洲福利一区二区精品秒拍| 久久精品国产亚洲AV高清热|