Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ファイルのリストを含むディレクトリがあります。上記のディレクトリのすべての内容から最新のファイルを取得したかったのです。どうすればいいですか?
このコードを使用していますが、最新のファイルを取得していません。助けてください。
def fileDir = new File("A/B").listFiles().first()
ありがとう。
単純な:
new File( 'A/B' ).listFiles()?.sort { -it.lastModified() }?.head()
(最新のファイルが最初に必要なため、負の lastModified を取ります)