How i can get encoded(which libriary can do this) "a &" to "a%20%26" without using String.replace() function?

How I can get encoded(which java library can do this)

a & to a%20%26

without using String.replace() function?

URL Encoder -> a+%26

URIUtil.encodePath -> a%20&

UrlEscapers.urlFragmentEscaper().escape -> a%20&

org.apache.catalina.util.URLEncoder is the answer