Hi, I tried this code ..... But I getting "ConnectExcepti on".
I am using a proxy.
[code=java]
import java.net.*;
import java.io.*;
public class URLRead {
/** Creates a new instance of URLRead */
public URLRead() {
}
public static void main(String args[]) throws Exception
{
//URL url = new URL("http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html");
/*System.out.pri ntln("Protocol: " + url.getProtocol ()+"\t"+
"Host: " + url.getHost() + "\t" +
"Port: " + url.getPort() + "\t" +
"Path: " + url.getPath() + "\t" +
"File: " + url.getFile()); */
URL url = new URL("http","jav a.sun.com",8080 ,"/j2se/1.4.2/docs/api/java/net/URL.html");
InputStream in = url.openConnect ion().getInputS tream();
FileOutputStrea m out = new FileOutputStrea m("c:/test.html");
int c;
while((c=in.rea d())!=-1) out.write(c);
in.close();
out.close();
System.out.prin tln("Done...... .....");
}
}
[/code]
Debasis Jana
I am using a proxy.
[code=java]
import java.net.*;
import java.io.*;
public class URLRead {
/** Creates a new instance of URLRead */
public URLRead() {
}
public static void main(String args[]) throws Exception
{
//URL url = new URL("http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html");
/*System.out.pri ntln("Protocol: " + url.getProtocol ()+"\t"+
"Host: " + url.getHost() + "\t" +
"Port: " + url.getPort() + "\t" +
"Path: " + url.getPath() + "\t" +
"File: " + url.getFile()); */
URL url = new URL("http","jav a.sun.com",8080 ,"/j2se/1.4.2/docs/api/java/net/URL.html");
InputStream in = url.openConnect ion().getInputS tream();
FileOutputStrea m out = new FileOutputStrea m("c:/test.html");
int c;
while((c=in.rea d())!=-1) out.write(c);
in.close();
out.close();
System.out.prin tln("Done...... .....");
}
}
[/code]
Debasis Jana
Comment