[填空题] 请在下列程序的空白处,填上适当的内容: Import java.awt.*; Import java.util.*; Class BufferTest Public static

17 查阅

[填空题] 请在下列程序的空白处,填上适当的内容:

Import java.awt.*;

Import java.util.*;

Class BufferTest

Public static void main(string args[])

Throws IOException

FileOutputStream unbuf=

new FileOutputStream("test.one");

BufferedOutputStream buf=

new______(new FileOutputStream("test.two"));

System.out.println

("write file unbuffered:"+time(unbuf)+"ms");

System.out.println

("write file buffered:"+time(buf)+"ms");

Static int time(OutputStream os)

Throws IOException

Date then=new Date();

for(int i=0;i<50000;i++)

os.write(1);

os.close();

return(int)(()new Date()).getTime()-then.getTime());

参考答案:

BufferedOutputStream

从前面变量buf的类型可以看出应为BuffeIed-OutputStream。

计算机考试