<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
    主站蜘蛛池模板: 国拍在线精品视频免费观看| 日批视频网址免费观看| 国产精品成人观看视频免费| 亚洲男人天堂2017| 久久久久国产免费| 国产亚洲精品精华液| a级成人毛片免费图片| 日本红怡院亚洲红怡院最新 | 国产乱子影视频上线免费观看| 亚洲人配人种jizz| 免费看的一级毛片| 午夜在线亚洲男人午在线| 国产一区二区三区免费看| 四虎影视在线看免费观看| 中文字幕精品亚洲无线码一区| 中文字幕看片在线a免费| 水蜜桃亚洲一二三四在线| 亚洲黄色免费网址| 亚洲成av人片在线天堂无| 亚洲精品岛国片在线观看| 国产拍拍拍无码视频免费| 337p日本欧洲亚洲大胆艺术| 97在线线免费观看视频在线观看| 中文字幕无码亚洲欧洲日韩| 国产在线a不卡免费视频| 久久免费99精品国产自在现线 | 亚洲人成电影在线播放| 另类免费视频一区二区在线观看 | 日韩在线天堂免费观看| 免费看一级高潮毛片| 亚洲国产精品无码中文字| 国产乱码免费卡1卡二卡3卡| 羞羞视频网站免费入口| 国产亚洲精品观看91在线| 亚洲最大免费视频网| 春暖花开亚洲性无区一区二区| 亚洲一区二区三区香蕉| 国产无人区码卡二卡三卡免费| 深夜福利在线视频免费| 亚洲自偷精品视频自拍| 免费一级做a爰片性色毛片|