title: Java Properties object to String
body: <p>I have a Java <code>Properties</code> object that I load from an in-memory <code>String</code>, that was previously loaded into memory from the actual <code>.properties</code> file like this:</p>
  
  <pre><code>this.propertyFilesCache.put(file, FileUtils.fileToString(propFile));
  </code></pre>
  
  <p>The util <code>fileToString</code> actually reads in the text from the file and the rest of the code stores it in a <code>HashMap</code> called <code>propertyFilesCache</code>.  Later, I read the file text from the <code>HashMap</code> as a <code>String</code> and reload it into a Java <code>Properties</code> object like so:</p>
  
  <pre><code>String propFileStr = this.propertyFilesCache.get(fileName);
  Properties tempProps = new Properties();
  try {
      tempProps.load(new ByteArrayInputStream(propFileStr.getBytes()));
  } catch (Exception e) {
      log.debug(e.getMessage());
  }
  tempProps.setProperty(prop, propVal);
  </code></pre>
  
  <p>At this point, I've replaced my property in my in-memory property file and I want to get the text from the <code>Properties</code> object as if I was reading a <code>File</code> object like I did up above.  Is there a simple way to do this or am I going to have to iterate over the properties and create the <code>String</code> manually?</p>