hehe 好奇怪的问题你可以在FILE NEW 的前或者后取SYSTEM current time 就可以算是了如果你想算精确的时间 可以取前后的时间差
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(); } } }
ps:以上方法在windows下可以这样取
现在给出一个能取到具体时间的程序: 代码如下: /* * FirstTest.java * * Created on 2006年7月12日, 下午3:25 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package firstnetbeanspro; import java.io.*; /** * * @author xiaotang */ public class FirstTest {
/** Creates a new instance of FirstTest */ public FirstTest() { }
public static void main(String[] args) { try { Process p = Runtime.getRuntime().exec("cmd /C dir c:\\reponse.log /tc"); InputStream is = p.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuffer sb = new StringBuffer(); String str; int i=0; while((str = br.readLine()) != null){ i++; if(i == 6){ System.out.println(str.substring(0,17)); } }
好奇怪的问题你可以在FILE NEW 的前或者后取SYSTEM current time 就可以算是了如果你想算精确的时间
可以取前后的时间差
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(); }
}
}
代码如下:
/*
* FirstTest.java
*
* Created on 2006年7月12日, 下午3:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/package firstnetbeanspro;
import java.io.*;
/**
*
* @author xiaotang
*/
public class FirstTest {
/** Creates a new instance of FirstTest */
public FirstTest() {
}
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("cmd /C dir c:\\reponse.log /tc");
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuffer sb = new StringBuffer();
String str;
int i=0;
while((str = br.readLine()) != null){
i++;
if(i == 6){
System.out.println(str.substring(0,17));
}
}
} catch (java.io.IOException exc) {
exc.printStackTrace();
}
}
}