Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/ioStreamConstructor/afterInputStreamFromLiteral.java
Artemiy Sartakov 67e36d74a5 IOStreamConstructorInspection: added inspection (IDEA-171230)
Inspection suggests conversions:
1. FileInputStream -> Files.newInputStream
2. FileOutputStream -> Files.newOutputStream
in cases when FileInputStream can be replaced with InputStream.
Also, it reuses path variable after conversion when possible (path variable should be effectively final).

GitOrigin-RevId: 474dcaeeb5336fcc8330b4b3ed65d443042ecf2f
2022-01-25 07:01:39 +00:00

13 lines
303 B
Java

// "Replace with 'Files.newInputStream'" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
class Foo {
void test(File file) {
try (InputStream is = Files.newInputStream(Path.of("foo"))) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}