One possible reason may be missing proper imports. There must be imports like:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
For more you can have a look on discussion here:
http://stackoverflow.com/questions/9977221/open-url-in-java-to-get-the-content[
^]
Hope that issue will be resolved, if not please update us with new error message u get. Thanks.