@@ -0,0 +1,1912 @@
+%0A/*%0A * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.%0A *%0A * $Id$%0A */%0A%0Apackage org.dellroad.stuff.spring;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.StringWriter;%0A%0Aimport org.springframework.beans.factory.config.AbstractFactoryBean;%0Aimport org.springframework.core.io.Resource;%0A%0A/**%0A * Spring factory bean that reads in a Spring %7B@link Resource%7D and converts it to a %7B@link String%7D.%0A */%0Apublic class ResourceReaderFactoryBean extends AbstractFactoryBean%3CString%3E %7B%0A%0A    private Resource resource;%0A    private String charset = %22UTF-8%22;%0A%0A    /**%0A     * Configure the resource containing the %7B@link String value%7D.%0A     */%0A    public void setResource(Resource resource) %7B%0A        this.resource = resource;%0A    %7D%0A%0A    /**%0A     * Configure the character encoding for the resource. Default is %7B@code UTF-8%7D.%0A     */%0A    public void setCharacterEncoding(String charset) %7B%0A        this.charset = charset;%0A    %7D%0A%0A    @Override%0A    public Class%3CString%3E getObjectType() %7B%0A        return String.class;%0A    %7D%0A%0A    @Override%0A    public void afterPropertiesSet() throws Exception %7B%0A        super.afterPropertiesSet();%0A        if (this.resource == null)%0A            throw new Exception(%22no resource configured%22);%0A    %7D%0A%0A    @Override%0A    protected String createInstance() throws IOException %7B%0A        InputStream input = this.resource.getInputStream();%0A        try %7B%0A            InputStreamReader reader = new InputStreamReader(input, this.charset);%0A            StringWriter writer = new StringWriter();%0A            char%5B%5D buf = new char%5B4096%5D;%0A            int r;%0A            while ((r = reader.read(buf)) != -1)%0A                writer.write(buf, 0, r);%0A            return writer.toString();%0A        %7D finally %7B%0A            try %7B%0A                input.close();%0A            %7D catch (IOException e) %7B%0A                // ignore%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A%0A

Add utility class to read in a String from a Resource.