private final void alignBuffer ( final int diff ) throws IOException { if ( bufOutput . remaining ( ) < diff ) { flushBuffer ( ) ; } bufOutput . put ( MAGIC_PADDING ) ; // Magic for Padding int i = 1 ; for ( ; i + 8 <= diff ; i += 8 ) { bufOutput . putLong ( 0L ) ; } for ( ; i + 4 <= diff ; i += 4 ) { bufOutput . putInt ( 0 ) ; } switch ( diff - i ) { case 3 : bufOutput . put ( ( byte ) 0 ) ; case 2 : bufOutput . putShort ( ( short ) 0 ) ; break ; case 1 : bufOutput . put ( ( byte ) 0 ) ; } }
Pad output buffer with NULL to complete alignment