日期:2014-05-20 浏览次数:21106 次
try { Process p = Runtime.getRuntime().exec( "cmd /C dir F:\\test4\\a2.html /tc");//这个地方的\\不能用/替代 InputStream is = p.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String result; String getTime = null; while ((result = br.readLine()) != null) { String[] str = result.split(" "); for (int i = str.length - 1; i >= 0; i--) { if (str[i].equals("a2.html")) { getTime = str[0] + " " + str[2]; } } } System.out.println("a2.html 文件的创建日期是:" + getTime); } catch (java.io.IOException exc) { exc.printStackTrace(); } // String ss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") .format((new File("F:\\test4\\a2.html").lastModified())); System.out.println("最后修改时间:"+ss);