Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can make use of <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URL.html" rel="noreferrer"><code>java.net.URL</code></a> and/or <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html" rel="noreferrer"><code>java.net.URLConnection</code></a>. </p> <pre><code>URL url = new URL("http://stackoverflow.com"); try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) { for (String line; (line = reader.readLine()) != null;) { System.out.println(line); } } </code></pre> <p>Also see the <a href="http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html" rel="noreferrer">Oracle's simple tutorial</a> on the subject. It's however a bit verbose. To end up with less verbose code, you may want to consider <a href="http://hc.apache.org/httpcomponents-client-ga/index.html" rel="noreferrer">Apache HttpClient</a> instead.</p> <p>By the way: if your next question is "How to process HTML result?", then the answer is "<a href="https://stackoverflow.com/questions/3152138/what-are-the-pros-and-cons-of-the-leading-java-html-parsers/3154281#3154281">Use a HTML parser</a>. <a href="https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags">No, don't use regex for this</a>.".</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests">Using java.net.URLConnection to fire and handle HTTP requests</a></li> <li><a href="https://stackoverflow.com/questions/3152138/what-are-the-pros-and-cons-of-the-leading-java-html-parsers">What are the pros and cons of the leading Java HTML parsers?</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload