Here you can find the source of saveMetaClassToFile(File baseDir, String clazzDef, String metaPackageName, Class> fromClazz)
public static void saveMetaClassToFile(File baseDir, String clazzDef, String metaPackageName, Class<?> fromClazz) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileWriter; public class Main { public static void saveMetaClassToFile(File baseDir, String clazzDef, String metaPackageName, Class<?> fromClazz) throws Exception { String clazzPcg = packageNameHelper(fromClazz, metaPackageName); String[] pcg = clazzPcg.split("\\."); File dest = baseDir;//from ww w .ja v a 2 s . com for (String p : pcg) { dest = new File(dest, p); if (!dest.exists()) dest.mkdir(); } dest = new File(dest, classNameHelper(fromClazz) + ".java"); FileWriter write = new FileWriter(dest); write.write(clazzDef); write.close(); } protected static String packageNameHelper(Class<?> from, String metaPackageName) { String pcgName = ""; if (metaPackageName != null) { pcgName = from.getPackage().getName() + "." + metaPackageName; } else { pcgName = from.getPackage().getName(); } return pcgName; } protected static String classNameHelper(Class<?> from) { return from.getSimpleName() + "_"; } }