Downloading a web page using URL and URLConnection classes
import java.io.BufferedInputStream; import java.net.URL; import java.net.URLConnection; public class Main { public static void main(String[] args) throws Exception { URLConnection urlc = new URL("http://www.google.com").openConnection(); BufferedInputStream buffer = new BufferedInputStream(urlc.getInputStream()); int byteRead; while ((byteRead = buffer.read()) != -1){ System.out.println((char) byteRead); } buffer.close(); } }