Code example for JavaFileObject

Methods: openWriter

0
        Template template = null;
 
        PrintWriter w =  null;
        try { 
            template = Velocity.getTemplate(templatePath);
            w = new PrintWriter(jfo.openWriter());
            template.merge(context, w);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new IOException("Impossible to generate annotation database.", ex);
        } finally { 
            if( w != null ) {
                try { 
                    w.close();
                } catch( Exception ex ) {
                    ex.printStackTrace();
                    throw new IOException("Impossible to close annotation database.", ex);
                } 
            } 
        }