001 package grails.plugins.wordpress.ssl; 002 003 import java.io.BufferedReader; 004 import java.io.InputStream; 005 import java.io.InputStreamReader; 006 import java.net.URL; 007 import java.net.URLConnection; 008 009 /** 010 * @author Daryl Banttari 011 * 012 */ 013 public class TestSSL { 014 015 public static void main(String[] args) { 016 // default url: 017 018 String urlString = "https://svn.codehaus.org/grails-plugins"; 019 020 // if any url specified, use that instead: 021 022 if(args.length > 0) { 023 urlString = args[0]; 024 } 025 System.out.println("Connecting to " + urlString + "..."); 026 027 try { 028 // convert user string to URL object 029 030 URL url = new URL(urlString); 031 032 // connect! 033 034 URLConnection cnx = url.openConnection(); 035 cnx.connect(); 036 037 // read the page returned 038 039 InputStream ins = cnx.getInputStream(); 040 BufferedReader in = new BufferedReader(new InputStreamReader(ins)); 041 String curline; 042 while( (curline = in.readLine()) != null ) { 043 System.out.println(curline); 044 } 045 046 // close the connection 047 048 ins.close(); 049 } 050 catch(Throwable t) { 051 t.printStackTrace(); 052 } 053 054 } 055 }