public static void emitCode ( File outputFolder , String fileName , String code , String encoding ) { try { File javaFile = new File ( outputFolder , File . separator + fileName ) ; javaFile . getParentFile ( ) . mkdirs ( ) ; javaFile . createNewFile ( ) ; PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( new FileOutputStream ( javaFile , false ) , encoding ) ) ; BufferedWriter out = new BufferedWriter ( writer ) ; out . write ( code ) ; out . close ( ) ; } catch ( IOException e ) { log . error ( "Error when saving class file: " + fileName ) ; e . printStackTrace ( ) ; } }
Emits generated code to a file .