Hi,
I have started to use Roaster (standalone) to generate some java code.
When you havea org.jboss.forge.roaster.model.source.JavaClassSource, what is the best way
to write the content into a file?
I could not find anything. How are other developers using Roaster?
I came up with this method (based on google guava):
public static void toFile(JavaClassSource javaClass, File srcFolder) throws IOException {
File f = srcFolder;
String[] parts = javaClass.getPackage().split("\\.");
for (String n : parts) {
f = new File(f, n);
}
f = new File(f, javaClass.getName() + ".java");
Files.createParentDirs(f);
Files.write(javaClass.toString(), f, Charsets.UTF_8);
}
Posted by forums
Original post:
https://developer.jboss.org/message/905590#905590