Reports multiple java.io.File attribute checks in a row, such as: These calls can be replaced with a bulk Files.readAttributes call. Usually the bulk method is more performant then multiple attribute checks.

Example:


boolean isNewFile(File file, long lastModified) throws IOException {
  return file.isFile() && file.lastModified() > lastModified;
}

After the quick-fix is applied:


boolean isNewFile(File file, long lastModified) throws IOException {
  BasicFileAttributes fileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
  return fileAttributes.isRegularFile() && fileAttributes.lastModifiedTime().toMillis() > lastModified;
}

This inspection does not show a warning if IOException is not handled in the current context, but the quick-fix is still available.

This inspection only reports if the language level of the project or module is 7 or higher.

New in 2022.1