Reader rdr = in.getReader(); if (rdr != null) rdr.close(); htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) is.close(); }
TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out);  Reader rdr = in.getReader(); if (rdr != null) rdr.close(); htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) is.close(); }
  public void transformSummaryToHTML(Writer htmlWriter)    throws IOException, TransformerException {    ByteArrayOutputStream summaryOut = new ByteArrayOutputStream( 8096 );    reportSummary( summaryOut );    String summaryXML = summaryOut.toString();    StreamSource in = new StreamSource( new StringReader( summaryXML ) );    StreamResult out = new StreamResult( htmlWriter );    InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl");    if ( xslInputStream == null )      throw new IOException("Could not load summary stylesheet");    StreamSource xsl = new StreamSource( xslInputStream );      TransformerFactory tf = TransformerFactory.newInstance();    Transformer transformer = tf.newTransformer( xsl );    transformer.transform( in, out );    Reader rdr = in.getReader();    if (rdr != null)      rdr.close();    htmlWriter.close();    InputStream is = xsl.getInputStream();     if (is != null)      is.close();  }