Link to home
Start Free TrialLog in
Avatar of jaxrpc
jaxrpc

asked on

getting URL content from https sites

hi

i have the follow code that works well when i try to get the content off non https sites like www.yahoo.com or www.google.com but when i  try to get the content from https sites it gives me an hostexception error. It seems that it is not able to get content from https sites. Any way to do this?
import java.net.*;
import java.io.*;
 
public class jget 
{
  public static void main ( String[] args ) throws IOException 
  {
    try 
    {
        URL url = new URL("http://www.yahoo.com");
    
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String str;
 
        while ((str = in.readLine()) != null) 
        {
          System.out.println(str);
        }
 
        in.close();
    } 
    catch (MalformedURLException e) {} 
    catch (IOException e) {}
  }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dejan Pažin
Dejan Pažin
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial