This java example will show how to get the contents of a webpage programmatically as a string using straight up java, java 7, guava and apache commons IOUtils. A similar example shows how to read the content of a webpage using groovy
Straight up Java
Java 7 File I/O
Google Guava
Apache Commons