import java.io.*; public class Test { public static void main(String[] args) { try { Process p = Runtime.getRuntime().exec("cmd /C dir c:\\temp\\xx.txt /tc"); InputStream is = p.getInputStream(); int i; while((i=is.read())!=-1) System.out.print((char)i); } catch (java.io.IOException exc) { exc.printStackTrace(); } } } 从里面提取吧
创建时间不知道, 最后修改时间可以用lastModified()
import java.io.*; import import java.text.SimpleDateFormat; public class Test{ public static void main(String[] args){ try{ String strDateTime = ""; File f = new File("path/file"); long fLastMod = f.lastModified(); String datetimeformat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdateformat = new SimpleDateFormat(datetimeformat); Timestamp ts = new Timestamp(fLastMod); strDateTime = sdateformat.format(ts); }catch(Exception e){
public class Test {
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("cmd /C dir c:\\temp\\xx.txt /tc");
InputStream is = p.getInputStream();
int i;
while((i=is.read())!=-1) System.out.print((char)i);
} catch (java.io.IOException exc) { exc.printStackTrace(); }
}
} 从里面提取吧
最后修改时间可以用lastModified()
import import java.text.SimpleDateFormat;
public class Test{
public static void main(String[] args){
try{
String strDateTime = "";
File f = new File("path/file");
long fLastMod = f.lastModified();
String datetimeformat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdateformat = new SimpleDateFormat(datetimeformat);
Timestamp ts = new Timestamp(fLastMod);
strDateTime = sdateformat.format(ts);
}catch(Exception e){
}
}
}