private static HasInputStream wrap(final HasInputStream hasResourceStream, final boolean doEncode) {
        return new HasInputStream() {
            @Override
            public InputStream getInputStream() throws IOException {
                return new Base64InputStream(hasResourceStream.getInputStream(), doEncode);
            }

            @Override
            public long writeContent(OutputStream outputStream) throws IOException {
                Base64OutputStream codec = new Base64OutputStream(outputStream, doEncode);
                try {
                    return hasResourceStream.writeContent(codec);
                } finally {
                    codec.flush();
                    codec.close();
                }
            }
        };
    }
private static HasInputStream wrap ( final HasInputStream hasResourceStream , final boolean doEncode ) { return new HasInputStream ( ) { @ Override public InputStream getInputStream ( ) throws IOException { return new Base64InputStream ( hasResourceStream . getInputStream ( ) , doEncode ) ; } @ Override public long writeContent ( OutputStream outputStream ) throws IOException { Base64OutputStream codec = new Base64OutputStream ( outputStream , doEncode ) ; try { return hasResourceStream . writeContent ( codec ) ; } finally { codec . flush ( ) ; codec . close ( ) ; } } } ; }
Returns a {@link HasInputStream} as a lazy way to wrap an input stream with a base64 encode/decode stream

@param hasResourceStream source
@param doEncode          true to encode

@return lazy stream