PDF 课件和源代码下载地址:
https://github.com/geektime-geekbang/LetsJava
作者回复: 这门课里我管它叫做俄罗斯套娃模式,这种套路的官方真名叫做装饰者模式
作者回复: new PrintWriter(file)的代码是:
public PrintWriter(File file) throws FileNotFoundException {
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))),
false);
}
Look at 上面的 new OutputStreamWriter,这种简化的方式下,JDK把这个OutputStreamWriter给create 好了。
PS:查看代码的方式是按住ctrl/command(for mac),鼠标单击。