本文介绍了Java PrintStream的意义和使用方法在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现许多程序员在他们的代码中使用PrintStream。我找了这个,但未能清楚地了解它的意义,为什么要使用它?



与其他输出流不同,PrintStream永远不会抛出IOException,数据会自动刷新到文件,即在写入字节数组后自动调用flush方法。



那么如果自动调用flush会有什么好处?



private PrintStream x = null;



现在,如果有人宣布像这样的x,可能是什么原因?

I found many programmers using PrintStream in their codes. I looked for this,but failed to get the clear idea of its significance,Why to use it?

"Unlike other output streams, a PrintStream never throws an IOException and the data is flushed to a file automatically i.e. the flush method is automatically invoked after a byte array is written."

So what's the benefit if flush is automatically invoked?

private PrintStream x = null;

Now what could be the possible reasons if someone declares x like this?

推荐答案


这篇关于Java PrintStream的意义和使用方法在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 05:47