Search code examples
javabytearrayoutputstream

Is it OK ByteArrayOutputStream is not closed


I am reading the following Java file: https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java?revision=1709154&view=co

In the linked code, the ByteArrayOutputStream is initialized but not CLOSED, is it OK? In my opinion, as ByteArrayOutputStream is Closeable, it should be closed eventually


Solution

  • Read the Javadoc:

    Closing a ByteArrayOutputStream has no effect.