1. public class TestHTTP 
  2.     public static void main(String[] args) 
  3.     { 
  4.         try 
  5.         { 
  6.             URL url = new URL("http://www.51cto.com/glblong.txt"); 
  7.             URLConnection conn = url.openConnection(); 
  8.             InputStream is = conn.getInputStream(); 
  9.  
  10.             int length = 0
  11.             byte[] buffer = new byte[1024]; 
  12.             while (-1 != (length = is.read(buffer))) 
  13.             { 
  14.                 System.out.print(new String(buffer, 0, length)); 
  15.             } 
  16.         } 
  17.         catch (MalformedURLException e) 
  18.         { 
  19.             e.printStackTrace(); 
  20.         } 
  21.         catch (IOException e) 
  22.         { 
  23.             e.printStackTrace(); 
  24.         } 
  25.     }