aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes  i cann't find any problem with this but it don't connect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark " i cann Watch " i cann New topic
Author

i cann't find any problem with this but it don't connect

Abhijith Sugunan
Greenhorn

Joined: Aug 04, 2012
Posts: 10
/*Always i get
No Date Avaliable
Content Type : null
*/


import java.net.*;
import java.io.*;
import java.util.Date;

class urlTest {

public static void main(String [] args) throws Exception {

URL url = new URL("http://www.internic.net");

URLConnection con = url.openConnection();

// getting date

long date = con.getDate();
if(date==0)
System.out.println("No Date Avaliable");
else
System.out.println("Date : "+ new Date(date));

// Getting content type of the page

System.out.println("Content Type : "+con.getContentType());




}


}
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
It works for me:

Date : Fri Dec 28 09:58:59 CET 2012
Content Type : text/html; charset=UTF-8
Abhijith Sugunan
Greenhorn

Joined: Aug 04, 2012
Posts: 10
I think there is some thing wrong with my JDK .I got this program correct on another computer . Which version of the JDK are you using IVAN..And when i tried it in a online editor then also i couldn't get the output..Anyway thanks for your replay..
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5

C:\temp\sme>java15 -version

C:\temp\sme>C:\langs\java\jdk1.5.0_18\bin\java.exe -version
java version "1.5.0_18"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_18-b02)
Java HotSpot(TM) Client VM (build 1.5.0_18-b02, mixed mode)

C:\temp\sme>java15 urlTest

C:\temp\sme>C:\langs\java\jdk1.5.0_18\bin\java.exe urlTest
Date : Fri Dec 28 13:50:12 CET 2012
Content Type : text/html; charset=UTF-8

C:\temp\sme>java16 -version

C:\temp\sme>"C:\langs\java\jdk1.6.0_37\bin\java.exe" -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) Client VM (build 20.12-b01, mixed mode, sharing)

C:\temp\sme>java16 urlTest

C:\temp\sme>"C:\langs\java\jdk1.6.0_37\bin\java.exe" urlTest
Date : Fri Dec 28 13:50:20 CET 2012
Content Type : text/html; charset=UTF-8

C:\temp\sme>java17 -version

C:\temp\sme>"C:\langs\java\jdk1.7.0_10\bin\java.exe" -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode, sharing)

C:\temp\sme>java17 urlTest

C:\temp\sme>"C:\langs\java\jdk1.7.0_10\bin\java.exe" urlTest
Date : Fri Dec 28 13:50:34 CET 2012
Content Type : text/html; charset=UTF-8
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i cann't find any problem with this but it don't connect