InputStreamRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!InputStreamRules\$).* as compiler argument.

Table of contents
  1. InputStreamTransferTo
  2. InputStreamReadAllBytes

InputStreamTransferTo

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("InputStreamTransferTo") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!InputStreamRules\$InputStreamTransferTo).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 long testInputStreamTransferTo() throws IOException {
-    return ByteStreams.copy(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream());
+    return new ByteArrayInputStream(new byte[0]).transferTo(new ByteArrayOutputStream());
   }

InputStreamReadAllBytes

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("InputStreamReadAllBytes") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!InputStreamRules\$InputStreamReadAllBytes).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 byte[] testInputStreamReadAllBytes() throws IOException {
-    return ByteStreams.toByteArray(new ByteArrayInputStream(new byte[0]));
+    return new ByteArrayInputStream(new byte[0]).readAllBytes();
   }

Copyright © 2017-2024 Picnic Technologies BV