package com.wanda.sso.client.servlet;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* Fileの時間を取得用クラス
*
* @author 徐小慧
* @version 1.0.0 $Id: Timetake 12254 2007-08-16 04:35:16Z
* xuxh $
* @since R1.0.0
*/
public class Timetake {
/**
* Fileの時間
* @param _file _file
* @return datetime datetime
*/
public static String getFileCreateDate(File _file) {
File file = _file;
try {
Process ls_proc = Runtime.getRuntime().exec(
"cmd.exe /c dir " + file.getAbsolutePath() + " /tc");
BufferedReader br = new BufferedReader(new InputStreamReader(ls_proc.getInputStream()));
for (int i = 0; i < 5; i++) {
br.readLine();
}
String stuff = br.readLine();
StringTokenizer st = new StringTokenizer(stuff);
String dateC = st.nextToken();
String time = st.nextToken();
String datetime = dateC.concat(time);
br.close();
return datetime;
} catch (Exception e) {
return null;
}
}
public static void main(String []args){
File file = new File("D:\\workspace\\ssoClient\\WEB-INF\\Setting.xml");
String time = Timetake.getFileCreateDate(file);
}
}