FileOutputStream和FileInputStream的构造方法

 

 

Which two create an InputStream and open file the “file.txt” for reading? (Choose Two) 

A. InputStream in=new FileReader(“file.txt”); 

B. InputStream in=new FileInputStream(“file.txt”); 

C. InputStream in=new InputStreamFileReader (“file.txt”, “read”); 

D. FileInputStream in=new FileReader(new File(“file.txt”)); 

E. FileInputStream in=new FileInputStream(new File(“file.txt”)); 

Answer: B, E 

 

 

 

Which two construct an OutputSream that appends to the file “file.txt”? (Choose Two) 

A. OutputStream out=new FileOutputStream(“file.txt”); 

B. OutputStream out=new FileOutputStream(“file.txt”, “append”); 

C. FileOutputStream out=new FileOutputStream(“file.txt”, true); 

D. FileOutputStream out=new FileOutputStream(new file(“file.txt”)); 

E. OutputStream out=new FileOutputStream(new File(“file.txt”)true); 

Answer: C, E 

 

 

Which constructs a BufferedIputStream? 

A. New BufferedInputStream(“in.txt”); 

B. New BufferedInputStream(new File(“in.txt”)); 

C. New BufferedInputStream(new Writer(“in.txt”)); 

D. New BufferedInputStream(new Writer(“in.txt”)); 

E. New BufferedInputStream(new InputStream(“in.txt”)); 

F. New BufferedInputStream(new FileInputStream(“in.txt”)); 

Answer: F

 

 

java.io 

Class FileInputStream

 

 

 

Constructor Summary

FileInputStream(File file) 

          Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.

 

FileInputStream(String name) 

          Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.

 

 

 

 

java.io 

Class FileOutputStream

 

 

Constructor Summary

FileOutputStream(File file) 

          Creates a file output stream to write to the file represented by the specified File object.

FileOutputStream(File file, boolean append) 

          Creates a file output stream to write to the file represented by the specified File object.

 

FileOutputStream(String name) 

          Creates an output file stream to write to the file with the specified name.

FileOutputStream(String name, boolean append) 

          Creates an output file stream to write to the file with the specified name.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值