Chapter 26 Using HTTP and HTTPS Connections in Java
The standard Java virtual machine provides HTTP connectivity with these classes in java.net package:
For details on these classes, see the JDK documentation. The following code shows a typical example. This code opens a connection, retrieves the data (text is assumed), and prints it:
URL url = new URL("http://www.sybase.com/");
URLConnection conn = url.openConnection();
conn.connect();
InputStreamReader content
= new InputStreamReader(conn.getInputStream());
for (int i=0; i != -1; i = content.read())
{
System.out.print((char) i);
}
Copyright © 2000 Sybase, Inc. All rights reserved. |