private static JavaCodeWriter getWriter(ClassBean classBean) throws IOException { String packagePath = classBean.getPackageName(); packagePath = packagePath.replace('.', '/'); File packageDirs = new File(outDir, packagePath); packageDirs.mkdirs(); File testFile = new File(packageDirs.getAbsoluteFile(), classBean.getName() + ".java"); if (testFile.exists()) { System.out.println("File already exists"); return null; } BufferedWriter out = new BufferedWriter(new FileWriter(testFile, false)); return new JavaCodeWriter(out); }