Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/ioStreamConstructor/afterInputStreamFromStringVar.java
Artemiy Sartakov c699fe0e24 IOStreamConstructorInspection: cr fixes (IJ-CR-20017):
1. report for arbitrary expressions that expect OutputStream / InputStream
2. report for arbitrary file creation arguments
3. check recursively if file creation argument is effectively final
4. reuse effectively final path variables if possible
5. use Paths.get() instead of Path.of() since 'of' method appeared only in java 11
6. info level for java 10 and higher

GitOrigin-RevId: 0a778328fe938faa0fe7eb2f199064f90b7a6d1b
2022-02-02 08:24:36 +00:00

13 lines
305 B
Java

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