使用Java在Windows上获取一个文件的创建时间
发布日期:2021-05-12 23:50:02 浏览次数:12 分类:精选文章

本文共 1537 字,大约阅读时间需要 5 分钟。

���������������������������Windows���������������

** * ��������������������������� * @param path ������������ * @return ������������������������������(2020:11:17 22:11:00)**```public static StringBuffer getFileCreateTime(String path){    StringBuffer commandStr = Conver.nsb("cmd /C dir ");    commandStr.append(DelStr.changeStrInStr(Conver.nsb(path), "/", "\\"));    // ������������������������"\", ��������� "/"    commandStr.append(" /tc");    StringBuffer str = Conver.nsb("");    try{        Process p = Runtime.getRuntime().exec(commandStr.toString());        InputStream is = p.getInputStream();        int number = 0;        int line = 0;        int totalCount = 0;        char ch = '\0';        for (;;){            number = is.read();            if (number == -1){                break;            }            ch = (char) number;            if (ch == '\n'){                ++line;                continue;            }            if (line >= 5){                str.append(ch);                ++totalCount;                if (totalCount >= 17){                    break;                }            }        }    }catch (java.io.IOException exc){        exc.printStackTrace();    }    // ���������������������    str = DelStr.changeStrInStr(str, "/", "-");    str = DelStr.changeStrInStr(str, "  ", " ");    str.append(":00");    return str;}

������������

            StringBuffer temp = FilePath.getFileCreateTime("c:/������/1.txt");            System.out.println(temp);        
上一篇:获取指定时间点的微信电脑版本地文件夹保存的图片
下一篇:使用Java获取一个动漫网站所有的动漫名

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月29日 07时18分40秒