Would a simple data.replaceAll( StringPool.SPACE, StringPool.DASH ) do just the same?