ImmutableBeanGenerator { public static void generate(String code, File generatedSource) { Generated g = generate(code); File file = new File(generatedSource, g.className().replace(".", File.separator) + ".java"); file.getParentFile().mkdirs(); try (FileOutputStream fos = new FileOutputStream(file)) { fos.write(g.generatedCode().getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException(e); } }  static void generate(String code, File generatedSource); static Generated generate(String code); static void scanAndGenerate(File directory, File generatedSourceDirectory);  }
@Test public void testJavaParser() throws IOException { String code = new String( Files.readAllBytes(new File("src/test/java/com/github/davidmoten/bean/Example.java").toPath()), StandardCharsets.UTF_8); System.out.println(ImmutableBeanGenerator.generate(code).generatedCode()); }