Java tutorial
/* * Output: * <HTML> <HEAD> <title> Java examples (example source code) Organized by topic </title> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <meta name="author" content="Demo Source and Support Ltd."/> <meta name="copyright" content="?2003 Demo Source and Support Ltd."/> <meta name="description" CONTENT=" Java examples (example source code) Organized by topic " /> <meta name="keywords" CONTENT=" Java examples (example source code) Organized by topic "/> <meta http-equiv="content-style-type" content="text/css"/> <LINK href="http://www.java2s.com/style/jss.css" type=text/css rel=stylesheet> <SCRIPT language=javascript1.2> ... ... */ import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class MainClass { public static void main(String args[]) throws Exception { int c; URL hp = new URL("http", "www.java2s.com", 80, "/"); URLConnection hpCon = hp.openConnection(); if (hpCon.getContentLength() > 0) { InputStream input = hpCon.getInputStream(); int i = hpCon.getContentLength(); while (((c = input.read()) != -1) && (--i > 0)) { System.out.print((char) c); } input.close(); } else { System.out.println("No Content Available"); } } }