byte[] bytes = getByteArr(); String base64String = Base64.encodeBase64String(bytes); byte[] backToBytes = Base64.decodeBase64(base64String);