Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/ioStreamConstructor/afterInputStreamArgumentFromFileVar.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

16 lines
345 B
Java

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