<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
    主站蜘蛛池模板: 韩国亚洲伊人久久综合影院| 亚洲91精品麻豆国产系列在线| 亚洲高清有码中文字| 久久久久国产精品免费看| 亚洲人成亚洲人成在线观看| h片在线播放免费高清| 亚洲五月午夜免费在线视频| 一级做受视频免费是看美女| 亚洲欧洲一区二区三区| 一级特黄录像视频免费| 亚洲综合无码精品一区二区三区| 黄色视频在线免费观看| 亚洲gv猛男gv无码男同短文| 久久免费精品一区二区| 亚洲黄网站wwwwww| 久久精品免费一区二区喷潮| 亚洲av无码一区二区三区天堂| 免费黄色一级毛片| 中文字幕av无码无卡免费| 日韩电影免费在线| 国产成人福利免费视频| 亚洲中文无码线在线观看| 成人性生活免费视频| 国产成人亚洲精品无码AV大片| 亚洲人妻av伦理| 久久精品电影免费动漫| 亚洲三级在线免费观看| 国产成人涩涩涩视频在线观看免费| 一级毛片**免费看试看20分钟| 久久精品国产亚洲| 男人的好免费观看在线视频| 免费无码一区二区| 亚洲视频一区二区在线观看| 免费黄色大片网站| 精品成人免费自拍视频| 亚洲综合无码一区二区痴汉| 亚洲片国产一区一级在线观看 | 一级毛片试看60分钟免费播放| 亚洲老妈激情一区二区三区| 日本zzzzwww大片免费| 日韩精品无码免费视频|