title: Will not closing a stringwriter cause a leak?
body: <p>I realize that in java the GC will eventually cleanup objects, but I'm asking if it is bad practice to not close your string writer, currently I am doing this:</p>
  
  <pre><code> private static String processTemplate(final Template template, final Map root) {
          StringWriter writer = new StringWriter();
          try {
              template.process(root, writer);
          } catch (TemplateException e) {
              logger.error(e.getMessage());
          } catch (IOException e) {
              logger.error(e.getMessage());
          }
          finally {
  
          }
  
          return writer.toString();
      }
  </code></pre>
  
  <p>Should I be closing the writer and creating a new String like this:</p>
  
  <pre><code>String result = "";
  
  ...
  
  finally {
    result = writer.toString();
    writer.close();
  }
  </code></pre>
  
  <p>Is this better to do?</p>