Skip to content
Advertisement

Sonar scan says Use try-with-resources or close this “Stream” in a “finally” clause

Sonar qube is giving me the following error:

Use try-with-resources or close this “Stream” in a “finally” clause

This is my code:

JavaScript

How can I fix this error?

Advertisement

Answer

define and open your stream this way:

JavaScript

Doing this, the system will automatically close the stream and you don’t need to worry about it

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement