Skip to content

Instantly share code, notes, and snippets.

@madan712
Created July 3, 2013 10:55
Show Gist options
  • Save madan712/5917012 to your computer and use it in GitHub Desktop.
Save madan712/5917012 to your computer and use it in GitHub Desktop.
Java Program to readl URL
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class URLReader {
public void readURL() {
try {
System.setProperty("javax.net.ssl.trustStore", "C:/Program Files/Java/jre6/lib/security/cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
URL url = new URL("https://testURL.com");
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = "";
while((line=in.readLine()) != null)
{
System.out.println(line);
}
//closing resource
in.close();
connection=null;
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args)
{
new URLReader().readURL();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment