GDirectory { public void output() { for (GClass gc : this.classes) { String newCode = gc.toCode(); File file = this.getFile(gc); if (file.exists()) { String existingCode = Read.fromFile(file, this.charset); if (newCode.equals(existingCode)) { this.touched.add(file); continue; } } file.getParentFile().mkdirs(); log.info("Saving {}", file); Write.toFile(file, newCode, this.charset); this.touched.add(file); } } GDirectory(String directory);  GDirectory(String directory, Charset charset); GClass getClass(String _fullClassName, Object... args); boolean exists(String fullClassName); void output(); void pruneIfNotTouched(); void pruneIfNotTouchedWithinUsedPackages(); List<File> getTouched(); void markTouched(File file); void markTouched(String fullClassName); List<File> getUsedDirectories(); List<File> getAllDirectories();  }
@Test public void testOutput() throws Exception { Assert.assertFalse(this.foo.exists()); GDirectory bin = new GDirectory(this.directory); GClass gc = bin.getClass("org.exigencecorp.Foo"); gc.getMethod("foo").setBody("int i = 0;"); bin.output(); Assert.assertEquals(Join.lines( "package org.exigencecorp;", "", "public class Foo {", "", " public void foo() {", " int i = 0;", " }", "", "}", ""), this.read(this.foo)); }