1 package com.fasterxml.jackson.databind.util; 2 3 import java.io.*; 4 import java.nio.ByteBuffer; 5 6 /** 7 * Simple {@link OutputStream} implementation that appends content 8 * written in given {@link ByteBuffer} instance. 9 */ 10 public class ByteBufferBackedOutputStream extends OutputStream { 11 protected final ByteBuffer _b; 12 ByteBufferBackedOutputStream(ByteBuffer buf)13 public ByteBufferBackedOutputStream(ByteBuffer buf) { _b = buf; } 14 write(int b)15 @Override public void write(int b) throws IOException { _b.put((byte) b); } write(byte[] bytes, int off, int len)16 @Override public void write(byte[] bytes, int off, int len) throws IOException { _b.put(bytes, off, len); } 17 } 18