int writeBytes ( OutputStream userstream ) throws IOException { if ( _patch . getParent ( ) != null ) { throw new IllegalStateException ( "Tried to flush while not on top-level" ) ; } try { BlockedByteInputStream datastream = new BlockedByteInputStream ( _manager . buffer ( ) ) ; int size = writeRecursive ( datastream , userstream , _patch ) ; return size ; } finally { _patch . reset ( ) ; } }
Writes everything we ve got into the output stream performing all necessary patches along the way .