java運行bat命令得到某個windows檔案的建立時間,bat建立時間

來源:互聯網
上載者:User

java運行bat命令得到某個windows檔案的建立時間,bat建立時間

原文:java運行bat命令得到某個windows檔案的建立時間

代碼:http://www.zuidaima.com/share/1550463260150784.htm

package com.zuidaima.util;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;/** *  * @author zuidaima.com *  */public class GetFileCreationDate {public static void main(String[] args) {try {Process proc = Runtime.getRuntime().exec("cmd /c dir c:\\zuidaima_com_logfile.log /tc");BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));String data = "";// it's quite stupid but workfor (int i = 0; i < 6; i++) {data = br.readLine();}System.out.println("Extracted value : " + data);// split by spaceStringTokenizer st = new StringTokenizer(data);String date = st.nextToken();// Get dateString time = st.nextToken();// Get timeSystem.out.println("Creation Date  : " + date);System.out.println("Creation Time  : " + time);} catch (IOException e) {e.printStackTrace();}}}
標籤: java windows bat 建立時間話題: 文本解析和檔案處理 指令碼和工具


怎用bat命令取某個檔案的建立時間

dir顯示檔案建立時間要加/tc參數。
@echo off
set p=d:\test
set fn=123.txt
pushd %p%
for /f %%i in ('dir/tc^|findstr /iec:"%fn%"') do set t=%%i
if "%t%" neq "2011-10-08" echo error!!!
 
怎使用bat檔案在Windows下運行Java程式

如果是jar檔案 java -jar *.jar

當前,確保你的classpath正確,跟jar檔案的路徑
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.