Closes this output stream if it has not already been closed and returns a {@link Storage} object which contains the bytes that have been written tothis output stream.
Note that this method may not be invoked a second time. This is because for some implementations it is not possible to create another Storage
object that can be read from and deleted independently (e.g. if the implementation writes to a file).
@return a Storage
object as described above.
@throws IOException if an I/O error occurs.
@throws IllegalStateException if this method has already been called.