simple http question.

I have this code

String strURL = "http://www.yahoo.com";

URL server = new URL(strURL);


HttpURLConnection connection = (HttpURLConnection)server.openConnection();

connection.connect();

System.out.println(connection.getResponseMessage());

InputStream in = connection.getInputStream();

while(in.available() > 0)
{
System.out.print((char)in.read());
}

it produces output something like

OK
<html><head>
<title>Yahoo!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l r (cz 1 lz 1 nz 1 oz 1 vz 1) gen true for "http://www.yahoo.com" r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l r (n 0 s 0 v 0 l 0) gen true for "http://www.yahoo.com" r (n 0 s 0 v 0 l 0))'>
<base href="http://www.ya

Any idea why the stream would stop after just a few characters?

If I try google.com then it only manages to get about 2 characters before stopping.

Thanks,
[1190 byte] By [SJ Smith] at [2007-11-20 1:11:50]
# 1 Re: simple http question.
Read the javadocs for Inputstream, you will get the answer. also try this snippet for your loop

int ch;
while ((ch = ins.read())>0){
System.out.print((char)ch);
}
tbear at 2007-11-10 2:18:38 >