import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
public class TestCompileTime {
public TestCompileTime() {
try {
System.out.println("build date:>>"+TestCompileTime.getCompileTimeStamp(this.getClass()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new TestCompileTime();
}
/**
* get date a class was compiled by looking at the corresponding class file in the jar.
* @author Zig
*/
public static Date getCompileTimeStamp( Class<?> cls ) throws IOException
{
ClassLoader loader = cls.getClassLoader();
String filename = cls.getName().replace('.', '/') + ".class";
// get the corresponding class file as a Resource.
URL resource=( loader!=null ) ?
loader.getResource( filename ) :
ClassLoader.getSystemResource( filename );
URLConnection connection = resource.openConnection();
// Note, we are using Connection.getLastModified not File.lastModifed.
// This will then work both or members of jars or standalone class files.
long time = connection.getLastModified();
return( time != 0L ) ? new Date( time ) : null;
}
}
'컴퓨터/IT' 카테고리의 다른 글
리눅스 포트포워딩 :iptables (0) | 2009.01.19 |
---|---|
우분투에서 와인으로 프로그램돌릴때 익스플로러도 제발 작동해라.. (0) | 2009.01.15 |
프로그래머 폰트라고 불리우는 고정폭 영어+한글 폰트 (0) | 2008.12.26 |
우분투 설치 고려사항 (진행중) (4) | 2008.11.06 |
우분투 8.10 + XP 심리스 20081029일자 스크린샷 (2) | 2008.10.29 |