Code example for Templates

Methods: newTransformer

0
        }); 
        t = transFactory.newTemplates(new StreamSource(is));
        templateCache.put(template, t);
        return t.newTransformer();
    } 
     
    private StreamSource getStreamSource(Bean genData) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try { 
            genData.write(bos);
        } finally { 
            bos.close();
        } 
        return new StreamSource(new ByteArrayInputStream(bos.toByteArray()));
    } 
     
    private StreamSource getStreamSource(String xml) throws IOException {
        StringReader sr = new StringReader(xml);
        return new StreamSource(sr);
    } 
Stop searching for code, let great code find you!  Add Codota to your java IDE