<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 閱讀(765) 評論(0)  編輯  收藏 所屬分類: httpClient
    主站蜘蛛池模板: 亚洲色无码国产精品网站可下载| 一本色道久久综合亚洲精品蜜桃冫 | 精品亚洲成AV人在线观看| 亚洲综合图片小说区热久久| 亚洲午夜在线一区| 无码免费又爽又高潮喷水的视频| 五月婷婷免费视频| 国产成在线观看免费视频| 妞干网手机免费视频| 亚洲伊人久久大香线蕉综合图片| 午夜亚洲www湿好大| 免费大片av手机看片高清| 在线成人精品国产区免费| 在线观看免费大黄网站| 亚洲码国产精品高潮在线| 亚洲粉嫩美白在线| 午夜爽爽爽男女免费观看影院| 夜夜爽免费888视频| 亚洲网站视频在线观看| 又硬又粗又长又爽免费看| 色窝窝免费一区二区三区| 好看的电影网站亚洲一区| 有色视频在线观看免费高清在线直播 | 中文字幕无线码中文字幕免费| 成人午夜大片免费7777| 内射少妇36P亚洲区| 97无码人妻福利免费公开在线视频 | 日韩视频免费一区二区三区| 亚洲av日韩综合一区在线观看| 四虎国产精品永免费| 亚洲?V无码乱码国产精品| 亚洲人6666成人观看| 无遮免费网站在线入口| 亚洲成a人片在线观看中文!!!| 成人片黄网站色大片免费观看APP| 亚洲欧洲自拍拍偷精品 美利坚 | 男女猛烈无遮掩视频免费软件| 成人看的午夜免费毛片| 亚洲AV日韩AV鸥美在线观看| 在线毛片片免费观看| 久久精品国产亚洲av四虎|