Improve docs

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-12-08 00:42:56 -03:00
parent 53a9449141
commit 3817dc2782

View File

@ -120,10 +120,14 @@ public class Test {
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#avoidfilestream">
<description>
Use Files.newInputStream(Paths.get(fileName)) instead of new FileInputStream(fileName).
Use Files.newOutputStream(Paths.get(fileName)) instead of new FileOutputStream(fileName).
Use Files.newBufferedReader(Paths.get(fileName)) instead of new FileReader(fileName).
Use Files.newBufferedWriter(Paths.get(fileName)) instead of new FileWriter(fileName).
The FileInputStream and FileOutputStream classes contains a finalizer method which will cause garbage collection pauses. See [JDK-8080225](https://bugs.openjdk.java.net/browse/JDK-8080225) for details.
The FileReader and FileWriter constructors instantiate FileInputStream and FileOutputStream, again causing garbage collection issues while finalizer methods are called.
* Use `Files.newInputStream(Paths.get(fileName))` instead of `new FileInputStream(fileName)`.
* Use `Files.newOutputStream(Paths.get(fileName))` instead of `new FileOutputStream(fileName)`.
* Use `Files.newBufferedReader(Paths.get(fileName))` instead of `new FileReader(fileName)`.
* Use `Files.newBufferedWriter(Paths.get(fileName))` instead of `new FileWriter(fileName)`.
</description>
<priority>1</priority>
<properties>