@Benchmark
	@BenchmarkMode(Mode.AverageTime)
	public void byteBufferFileOutputStream(final Configuration configuration) throws IOException {
		ByteBuffer buffer = ByteBuffer.allocate(BUFFER_CAPACITY);

		try (OutputStream stream = new FileOutputStream(configuration.file)) {
			for (long i = 0; i < LINES; ++i) {
				if (buffer.remaining() < DATA.length) {
					stream.write(buffer.array(), 0, buffer.position());
					buffer.rewind();
				}

				if (buffer.remaining() < DATA.length) {
					stream.write(DATA);
				} else {
					buffer.put(DATA);
				}
			}

			if (buffer.position() > 0) {
				stream.write(buffer.array(), 0, buffer.position());
			}
		}
	}
@ Benchmark @ BenchmarkMode ( Mode . AverageTime ) public void byteBufferFileOutputStream ( final Configuration configuration ) throws IOException { ByteBuffer buffer = ByteBuffer . allocate ( BUFFER_CAPACITY ) ; try ( OutputStream stream = new FileOutputStream ( configuration . file ) ) { for ( long i = 0 ; i < LINES ; ++ i ) { if ( buffer . remaining ( ) < DATA . length ) { stream . write ( buffer . array ( ) , 0 , buffer . position ( ) ) ; buffer . rewind ( ) ; } if ( buffer . remaining ( ) < DATA . length ) { stream . write ( DATA ) ; } else { buffer . put ( DATA ) ; } } if ( buffer . position ( ) > 0 ) { stream . write ( buffer . array ( ) , 0 , buffer . position ( ) ) ; } } }
Benchmarks writing via {@link FileOutputStream} with using a {@link ByteBuffer} for buffering.

@param configuration
Configuration with target file
@throws IOException
Failed to write to target file