Hello,
I have been programming in java for a very short time and would be very greatful
if any one can help with my problem.
************************************************************************************************************
I want to download a html file from a specified URL.
I've managed to this on internal web-pages but have not succeeded when accessing
web-pages outside the proxy server.
I know that I need to communicate to the proxy server and ask it to get the URL
web page but I don't know how to do this.
I have added the code that I have used to complete the successful bit.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
import java.io.*;
import java.net.*;
public class GetURL
{
public static void main(String[] args) {
InputStream in = null;
OutputStream out = null;
try
{
if ( (args.length !=1) && (args.length != 2) )
throw new IllegalArgumentException("Wrong number of
arguments");
URL url = new URL(args[0]);
in = url.openStream();
if ( args.length == 2 )
out = new FileOutputStream(args[1]);
else out = System.out;
byte[] buffer = new byte[4096];
int bytes_read;
while ( (bytes_read = in.read(buffer)) != -1 )
out.write(buffer, 0, bytes_read);
}
catch ( Exception e )
{
System.err.println(e);
System.err.println("Usage: java GetURL <URL> [<filename>]");
}
finally
{
try
{
in.close(); out.close();
}
catch ( Exception e )
{
}
}
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html