解决方案 »
- 请问,JPanel上放置了多个JToggleButton,如何统一处理这些button的事件
- 向懂swing的朋友求助!!!
- jTree如何添加JCheckBox
- 急急急!Firefox可以执行,IE就不可以
- DatagramSocket在多线程下使用的问题
- 用命令行执行,出现找不到MovementListener符号的错误,请高人指点
- 请教 自定义布局 方面的问题 很简单的 请帮我看看 谢谢!!
- 哪位可以讲讲编写ftp客户端的下载函数(方法)
- java在linux得安装问题 在线等 谢谢
- 有关native method的疑问?
- 关于捕获异常并返回执行问题
- 动态代理 invocationHandler参数问题
最终差别就在boolean autoFlush 第一true 第二false
private PrintStream(boolean autoFlush, OutputStream out) {
super(out);
this.autoFlush = autoFlush;
this.charOut = new OutputStreamWriter(this);
this.textOut = new BufferedWriter(charOut);
}
public PrintStream(File file) throws FileNotFoundException {
this(false, new FileOutputStream(file));
} public PrintStream(OutputStream out) {
this(out, false);
} public PrintStream(OutputStream out, boolean autoFlush) {
this(autoFlush, requireNonNull(out, "Null output stream"));
} private PrintStream(boolean autoFlush, OutputStream out) {
super(out);
this.autoFlush = autoFlush;
this.charOut = new OutputStreamWriter(this);
this.textOut = new BufferedWriter(charOut);
}
两者确实一样,因为你传file进去,它内部也会创建一个FileOutputStream
private PrintStream(boolean autoFlush, OutputStream out) {
super(out);
this.autoFlush = autoFlush;
this.charOut = new OutputStreamWriter(this);
this.textOut = new BufferedWriter(charOut);
}