Run the bat command in java to obtain the creation time of a windows file and the bat creation time.

Source: Internet
Author: User

Run the bat command in java to obtain the creation time of a windows file and the bat creation time.

Original article: run the bat command in java to obtain the creation time of a windows File

Code: 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();}}}
Tags: java windows bat creation time topics: Text parsing and file processing scripts and tools


How to use the bat command to obtain the creation time of a file

Dir: add the/tc parameter to the file creation time.
@ Echo off
Set p = d: \ test
Set fn1_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 !!!

How to Use the bat file to run Java programs in Windows

For the jar file java-jar *. jar

Currently, make sure that your classpath is correct and the path of the jar file is

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.