home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
lotus
/
eSuite.exe
/
eSuiteDPP
/
samples
/
weatherchart
/
GetWDataProxy.java
< prev
next >
Wrap
Text File
|
1998-01-09
|
2KB
|
84 lines
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// GetWDataProxy.java : read weather-data using proxy server
//
// Author: F. Salazar
// Created: June, 1997
//
// Copyright (c)1992-1997 Lotus Development Corp. All Rights Reserved.
//
/////////////////////////////////////////////////////////////////////////////////////////////////
/*******************************************************************************
Change History:
$Log: //reebok/xyzL/JavaComp/webpack/samples/weatherchart/GetWDataProxy.java
Rev 1.2.2.1 09 Jan 1998 10:52:10 jdonohue
Change package name to samples.weatherchart
Rev 1.2 03 Oct 1997 11:19:30 fsalazar
Correct for no-proxy read.
Rev 1.1 05 Aug 1997 10:15:40 fsalazar
Use webpack.samples.weatherchart package name.
*******************************************************************************/
package samples.weatherchart;
import java.io.*;
import java.net.*;
public class GetWDataProxy extends GetWData
{
private String m_sURL;
private String m_sProxy;
private int m_iPort;
public GetWDataProxy( String sURL, String sProxy, int port )
{
super();
m_sURL = new String( sURL );
m_sProxy = new String( sProxy );
m_iPort = port;
}
// Open a socket to proxy server, then issue HTTP GET request.
// Parse returned output to extract weather values.
// Example request strings:
//
// GET http://www.intellicast.com/weather/bos/curcond.dat HTTP/1.0\r\n\r\n
// GET http://www.intellicast.com/weather/lax/curcond.dat HTTP/1.0\r\n\r\n
public void read() throws IOException, MalformedURLException
{
String request = new String( "GET " + m_sURL + " HTTP/1.0\r\n\r\n" );
Socket sock = new Socket( m_sProxy, m_iPort );
BufferedInputStream bistr;
DataOutputStream dostr;
bistr = new BufferedInputStream( sock.getInputStream() );
dostr = new DataOutputStream( sock.getOutputStream() );
dostr.writeBytes( request );
if ( !parseStream( bistr, true ) )
{
System.out.print( "Data-format error in read().\r\n");
}
bistr.close();
dostr.close();
}
}
// end of GetWDataProxy.java
//////////////////////////////