Created
July 3, 2013 10:55
-
-
Save madan712/5917012 to your computer and use it in GitHub Desktop.
Java Program to readl URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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