title: Ways to convert String to Spring Resource
body: <p>I have a class with a resource property of type Resource in spring (<code>org.springframework.core.io.Resource</code>) which takes a file object as input. </p>
  
  <pre><code>setResource(Resource resource) 
    {
       this.resource = resource;
    }
  </code></pre>
  
  <p>However, I am reading a remote document through another custom API which returns the contents of the document as a String. </p>
  
  <pre><code>String xml = document.getContent();
  </code></pre>
  
  <p>I want to pass this xml as <code>Resource</code> in my <code>setResource</code> method. However, I don't know how can I cast String into <code>Resource</code>. </p>
  
  <p>Any ideas ??</p>