Do not use the removed FileInputStream.finalize() and FileOutputStream.finalize() methods

The finalize methods in java.io.FileInputStream and java.io.FileOutputStream are no longer available in Java SE 12 and later. Previously, the finalize method called the close method. You can close files by explicitly calling the close method or using try-with-resources. To close FileDescriptors that are no longer reachable, use the java.lang.ref.Cleaner class.

This rule has an automated fix to replace the method. Copy the custom configuration to your application build file to enable it.

For more information on the removed methods, see APIs Removed in Java SE 12.

For more information on the replacement methods, see Class FileInputStream documentation, Class FileOutputStream documentation, and Class java.lang.ref.Cleaner documentation.