I hav written the program in Java to download the details from the server....as follows....
[code=java]
import java.net.*;
import java.io.*;
import java.util.Date;
class urldemo
{
public static void main(String args[])throws Exception
{
int c;
URL hp=new URL("http://www.yahoo.com") ;
URLConnection hpcon=hp.openCo nnection();
long d=hpcon.getDate ();
if(d==0)
System.out.prin tln("no date");
else
System.out.prin tln("Date:"+new Date(d));
System.out.prin tln("Content Type:"+hpcon.ge tContentType()) ;
d=hpcon.getExpi ration();
if(d==0)
System.out.prin tln("No expire info:");
else
System.out.prin tln("Expires on:"+new Date(d));
d=hpcon.getLast Modified();
if(d==0)
System.out.prin tln("No modified info:");
else
System.out.prin tln("Modified on:"+new Date(d));
int len=hpcon.getCo ntentLength();
if(len==-1)
System.out.prin tln("No length");
else
System.out.prin tln("Content Length"+len);
if(len!=0)
{
System.out.prin tln("========== =====CONTENT=== =============== ");
InputStream input=hpcon.get InputStream();
int i=len;
while(((c=input .read())!=-1))
{
System.out.prin t((char)c);
}
input.close();
}
else
{
System.out.prin tln("Content Unavailable");
}
}
}
[/code]
But i did not get the output for that....I am getting the error like "Unknownhos t Exception"....K indly assist me on that....
[code=java]
import java.net.*;
import java.io.*;
import java.util.Date;
class urldemo
{
public static void main(String args[])throws Exception
{
int c;
URL hp=new URL("http://www.yahoo.com") ;
URLConnection hpcon=hp.openCo nnection();
long d=hpcon.getDate ();
if(d==0)
System.out.prin tln("no date");
else
System.out.prin tln("Date:"+new Date(d));
System.out.prin tln("Content Type:"+hpcon.ge tContentType()) ;
d=hpcon.getExpi ration();
if(d==0)
System.out.prin tln("No expire info:");
else
System.out.prin tln("Expires on:"+new Date(d));
d=hpcon.getLast Modified();
if(d==0)
System.out.prin tln("No modified info:");
else
System.out.prin tln("Modified on:"+new Date(d));
int len=hpcon.getCo ntentLength();
if(len==-1)
System.out.prin tln("No length");
else
System.out.prin tln("Content Length"+len);
if(len!=0)
{
System.out.prin tln("========== =====CONTENT=== =============== ");
InputStream input=hpcon.get InputStream();
int i=len;
while(((c=input .read())!=-1))
{
System.out.prin t((char)c);
}
input.close();
}
else
{
System.out.prin tln("Content Unavailable");
}
}
}
[/code]
But i did not get the output for that....I am getting the error like "Unknownhos t Exception"....K indly assist me on that....
Comment