Next message: Marc Lev: "We pay cash, now!"
Message-ID: <3914623D.B84FC759@stu.ust.hk>
Date: Sun, 07 May 2000 02:19:41 +0800
From: Brenda <cs_kyc@stu.ust.hk>
To: www-wca@w3.org
CC: cs_kyc@stu.ust.hk
Subject: HTTP problem. Urgently Need your help!!
I write and run a simple "get Internet page program" in local hard disk
with java program
(I have connected to Internet through the University), it usually throws
the
exception error message: Operation timed out: no further information.
However
if I run my program in Unix account, it works well.
Since I must do my exercise in local hark, I must find a way to get
Other
Internet Page from local server.
Thank you for your help.
Cheers,
Brenda
private final String location="http://java.sun.com";
private String results;
public HTTPost ()
{
try
{
URL url = new URL(location);
URLConnection connection = url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
PrintStream outStream =new
PrintStream(connection.getOutputStream());
BufferedInputStream buffer = new
BufferedInputStream(connection.getInputStream());
BufferedReader inStream= new BufferedReader(new
InputStreamReader(buffer));
String inputLine;
while (null != (inputLine = inStream.readLine()))
{
results = results + inputLine + "\n";
}
System.out.print (results);
inStream.close();
}
catch (MalformedURLException ex)
{
System.err.println(ex);
}
catch (IOException ex)
{
System.err.println(ex);
}
}