I hav written the program in Java to download the details from the server....as follows....
-
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.openConnection();
-
long d=hpcon.getDate();
-
if(d==0)
-
System.out.println("no date");
-
else
-
System.out.println("Date:"+new Date(d));
-
System.out.println("Content Type:"+hpcon.getContentType());
-
d=hpcon.getExpiration();
-
if(d==0)
-
System.out.println("No expire info:");
-
else
-
System.out.println("Expires on:"+new Date(d));
-
d=hpcon.getLastModified();
-
if(d==0)
-
System.out.println("No modified info:");
-
else
-
System.out.println("Modified on:"+new Date(d));
-
int len=hpcon.getContentLength();
-
if(len==-1)
-
System.out.println("No length");
-
else
-
System.out.println("Content Length"+len);
-
if(len!=0)
-
{
-
System.out.println("===============CONTENT==================");
-
InputStream input=hpcon.getInputStream();
-
int i=len;
-
while(((c=input.read())!=-1))
-
{
-
System.out.print((char)c);
-
}
-
input.close();
-
}
-
else
-
{
-
System.out.println("Content Unavailable");
-
}
-
}
-
}
-
But i did not get the output for that....I am getting the error like "Unknownhost Exception"....Kindly assist me on that....