Memory efficient way to replace string in Java
<p>We're about to release a site which displays up to 500 images at a time which are stored on Amazon. Since the urls are stored in our database with "http" instead of "https", I need to substitute the "http" with "https" every time the image url is retrieved. Here's the current code: </p>

<pre><code>static Pattern p = Pattern.compile("http");

Matcher m = p.matcher(urlSmall);;
String secureUrlSmall = m.replaceFirst("https");
return secureUrlSmall;
</code></pre>

<p>My concern is that by creating so many String objects I'll eat up Java heap space. Is there a better solution somehow involving StringBuilder, for example? </p>