public String getBinaryDataForXml(byte[] buffer) {        
        StringBuffer hexData = new StringBuffer();
        Base64Encoder encoder = new Base64Encoder();
        return encoder.encode(buffer);
    }
public String getBinaryDataForXml ( byte [ ] buffer ) { StringBuffer hexData = new StringBuffer ( ) ; Base64Encoder encoder = new Base64Encoder ( ) ; return encoder . encode ( buffer ) ; }
http://www.javaworld.com/javatips/jw-javatip117.html