Java tutorial
//package com.java2s; import java.lang.ref.SoftReference; public class Main { private static SoftReference<StringBuffer> strBfeCache; private static StringBuffer getStrBuf() { StringBuffer result = null; if (strBfeCache != null) result = strBfeCache.get(); if (result == null) { result = new StringBuffer(); strBfeCache = new SoftReference<StringBuffer>(result); } return result; } }