Here you can find the source of createAndGetOutputStream(String typename, String outputPath)
public static Writer createAndGetOutputStream(String typename, String outputPath) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { public static Writer createAndGetOutputStream(String typename, String outputPath) throws IOException { if (typename.indexOf('$') > 0) { System.out.println(typename); typename = typename.substring(0, typename.lastIndexOf('.')) + "." + typename.substring(typename.indexOf('$') + 1); }// www . ja va2s. co m File file = new File(outputPath, typename.replace('.', File.separatorChar) + ".java"); file.getParentFile().mkdirs(); file.createNewFile(); OutputStream os = new FileOutputStream(file); return new OutputStreamWriter(os, Charset.forName("UTF-8")); } }