Hello. I have a folder that contains a lot of large files, the names of which I do not know. I know only the relative path to the folder in which they are located. Without needing to download these files into my program, I need to check, say, for example, a month, and delete if yes.
Here I googled a way to find out the date the file was created along its path.
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class); System.out.println(" creationTime: " + attr.creationTime()); And how to get the name of all the paths to files? After all, as I understand
File myFolder = new File("путь к папке"); File[] files = myFolder.listFiles(); It loads the files themselves into the program, which I do not need because There are many files and they are large.
Fileobject (and its analogue from the new apiPath) is just an abstraction, and contains only the path. It may, for example, point to a non-existent file. Since you are using a new api, instead ofFile.list()useFiles.list( Path )(orFiles.newDirectoryStream( Path )if you have java 7). - zRrr