I need to read the absolute path, file name & size of the files in a directory. This is how I currently do it:
File diretory = <dir_path>;
File[] listFiles = directory.listFiles();
for (int i = 0; i < listFiles.length; i++) {
String fileName = file.getName();
String filePath = file.getAbsolutePath();
long fileLen = file.length();
long filelastModified = file.getLastModified();
...
}
My directory can have 1000s of files in it. Since I/O Operations being very expensive, is this the most optimal way to accomplish what I am doing?