此代码是从教程网站粘贴的,在我的机器(win7-amd64)中不起作用!顺便说一句,我想运行这段代码来获取公共文件的创建日期/时间。
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd /c dir c:\\logfile.log /tc");
BufferedReader br =
new BufferedReader(new InputStreamReader(proc.getInputStream()));
String data = "";
for (int i = 0; i < 6; i++) {
data = br.readLine();
}
System.out.println("Extracted value : " + data);
//split by space
StringTokenizer st = new StringTokenizer(data);
String date = st.nextToken();//Get date
String time = st.nextToken();//Get time
System.out.println("Creation Date : " + date);
System.out.println("Creation Time : " + time);