How do I find the last modified file in a directory in Java?

后端 未结 9 928
半阙折子戏
半阙折子戏 2020-11-28 09:51

How do I find the last modified file in a directory in java?

9条回答
  •  猫巷女王i
    2020-11-28 10:35

    Combine these two:

    1. You can get the last modified time of a File using File.lastModified().
    2. To list all of the files in a directory, use File.listFiles().

    Note that in Java the java.io.File object is used for both directories and files.

提交回复
热议问题