Please see the code snippet
try (InputStream inputStream = this.getClass().getClassLoader()
.getResourceAsStream("hello.txt");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
But sonarQube
complaints below error in the above line
Correctness - Nullcheck of value previously dereferenced(line starting with BufferedReader ) .
Please help to resolve this issue
这是因为getClassLoader().getResourceAsStream("hello.txt")
可以返回null
并且您在创建BufferedReader
之后就使用了它,而无需检查null值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.