public static synchronized void createSource ( Java . _ClassBody clazz ) throws IOException { if ( baseDir == null ) { throw new IOException ( "Base directory for output not set, use 'setBaseDirectory'" ) ; } String pkg = clazz . getPackage ( ) ; if ( pkg == null ) { pkg = "" ; // throw new IOException("Class package cannot be null"); } pkg = pkg . replace ( ' ' , ' ' ) ; File path = new File ( baseDir , pkg ) ; path . mkdirs ( ) ; try ( PrintWriter fp = new PrintWriter ( new FileWriter ( new File ( path , clazz . getName ( ) + ".java" ) ) ) ) { clazz . emit ( 0 , fp ) ; } }
Create the source file for a given class