Networking Java Book

Outputting the contents of the resource identified via a URL command-line argument
import java.io.InputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("http://google.com");
try (InputStream is = url.openStream()) {
int ch;
while ((ch = is.read()) != -1) {
System.out.print((char) ch);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}