Reputation: 533
I want to grab the source code of a page which contains the word "true" or "false". That's the only two words that would be on that page, no other formatting.
So I just need Java to URL connect to that page "http://example.com/example.php" and just grab the contents.
Upvotes: 4
Views: 7841
Reputation: 11920
Try this tutorial : Java URL example - Download the contents of a URL
Upvotes: 6
Reputation: 1893
There is an easy way to do that using Apache Commons IO. For example for mentioned action you can just write
URL url = new URL("http://example.com/example.php");
String content = IOUtils.toString(new InputStreamReader(
url.openStream()));
Upvotes: 2