The documentation for each API, including limited or external resources (for example, file descriptors or streams), will make it clear whose responsibility it is to clean up (in this case, close the stream). This is sometimes called "property."
In this case, the documentation states that the loadFont method loadFont not accept ownership of the stream. Therefore, it still belongs to you: your responsibility is to close the flow.
The easiest way to do this is with the try-with-resources statement.
source share