Code example for ByteArrayInputStream

0
public class LazyBSONDecoder implements BSONDecoder { 
    static final Logger LOG = Logger.getLogger( LazyBSONDecoder.class.getName() );
 
    public BSONObject readObject(byte[] b) {
        try { 
            return readObject( new ByteArrayInputStream( b ) );
        } 
        catch ( IOException ioe ){
            throw new BSONException( "should be impossible" , ioe );
        } 
    } 
 
    public BSONObject readObject(InputStream in) throws IOException {
        BSONCallback c = new LazyBSONCallback();
        decode( in , c );
        return (BSONObject)c.get();
    } 
 
    public int decode(byte[] b, BSONCallback callback) {
        try { 
            return decode( new ByteArrayInputStream( b ), callback );