新建一个流对象,下列( )选项的代码是错误的。
A: new BufferedWriter(new FileWriter("a.txt"));
B: new BufferedReader(new FileInputStream("a.dat"));
C: new DataOutputStream(new FileOutputStream("a.txt"));
D: new ObjectInputStream(new FileInputStream("a.dat"));
A: new BufferedWriter(new FileWriter("a.txt"));
B: new BufferedReader(new FileInputStream("a.dat"));
C: new DataOutputStream(new FileOutputStream("a.txt"));
D: new ObjectInputStream(new FileInputStream("a.dat"));
举一反三
- 新建一个流对象,下列( )选项的代码是错误的。 A: new BufferedWriter(new FileWriter("a.txt")); B: new BufferedReader(new FileInputStream("a.dat")); C: new DataOutputStream(new FileOutputStream("a.txt")); D: new ObjectInputStream(new FileInputStream("a.dat"));
- 下列写法错误的是 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 ("."));
- 下列哪个选项定义了带有缓存的文件字节输入流 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(...));
- 要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( ) 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”));
- 在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”));