public static Writer newWriter(ProtoModule module, String packageName, String fileName)
            throws IOException
    {
        String encoding = module.getEncoding();
        if (encoding == null || encoding.isEmpty())
            encoding = "UTF-8";

        File packageDir = new File(module.getOutputDir(), packageName.replace('.', '/'));
        if (!packageDir.exists())
            packageDir.mkdirs();

        File outputFile = new File(packageDir, fileName);
        FileOutputStream out = new FileOutputStream(outputFile);
        return new BufferedWriter(new OutputStreamWriter(out, encoding));
    }
Utilities and helpers for compiling protos.

@author David Yu
@created Jan 5, 2010
protostuff-compiler/src/main/java/io/protostuff/compiler/CompilerUtil.java