中国大学MOOC: (读写文件)下列语句执行时,若文件”customer.dat”不存在,则会产生的异常是________。FileInputStream fis = new FileInputStream(“customer.dat”);
举一反三
- 下列哪个选项定义了带有缓存的文件字节输入流 A: BufferedInputStream bis = new BufferedInputStream(new FileInputStream(...)); B: BufferedOutputStream bos = new BufferedOutputStream(new FileInputStream(...)); C: FileInputStream fis = new FileInputStream(new BufferedInputStream(...)); D: FileOutputStream fis = new FileOutputStream(new BufferedOutputStream(...));
- 中国大学MOOC: 若要打开的文件不存在,则会产生什么异常________
- 下列写法错误的是 A: File f = new File ("a.txt"); B: File f = new File ("d:\\a.txt"); C: FileInputStream fis = new FileInputStream (new File ("a.txt")); D: FileOutputStream fos = new FileOutputStream ( File ("."));
- 在J2EE中,利用下列构造函数准备对文件abc.txt操作,但文件abc.txt在当前目录不存在,不会产生运行时错误的是()。 A: BufferedReader breader=new BufferedReader(new FileReader("abc.txt")); B: PrintWriter out = new PrintWriter(new FileWriter(“abc.txt”),true); C: FileInputStream fin = new FileInputStream(“abc.txt”); D: OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(“abc.txt”));
- 要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( ) A: new FileInputStream(“myfile.dat”); B: new InputStreamReader(new FileInputStream(“myfile.dat”)); C: new BufferedReader(new InputStreamReader(new FileInputStream(“myfile.dat”); D: new RandomAccessFile raf=new RandomAccessFile(new File(“myfile.dat”,”rw”));