正确生成RandomAccessFile对象的语句是 ( ) A.File f=new File("readFile"); B.RandomAccessFile raF=new RandomAcccssFile(d:mydirFile3.txt,"rw"); C.RandomAccessFile raF=new RandomAccessFile("readwriteFile","rw"); D.RandomAccessFile raF=new RandomAccessFite("readwriteFile",rw)
举一反三
- 要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( ) 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”));
- 下面创建的输入或输出流对象( )能读或写Java的原始数据类型。 A: FileOutputStream fos = new FileOutputStream (“abc.dat”); B: DataOutputStream out = new DataOutputStream (fos); C: RandomAccessFile raf = new RandomAccessFile (“Class1.java”, ”rw”); D: FileOutputStream out = new FileOutputStream (“. / temp/ abc.txt”);
- 下面创建的输入或输出流对象哪个能读或写Java语言中的double类型的数据 A: FileOutputStream fos=new FileOutputStream("1.dat"); B: DataOutputStream out=new DataOutputStream(new FileOutputStream(“2.dat”)); C: RandomAccessFile raf = new RandomAccessFile("3.java" , "rw" ); D: DataInputStream in=new DataInputStream(new FileInputStream(“4.dat”));
- RandomAccessFile的构造函数的参数,RandomAccessFile( File file,String mode)。下列有关描述错误的是( ) A: r 以只读方式打开 B: rw打开以便读取和写入,如果文件不存在,尝试创建该文件 C: file为该文件对象,mode为访问模式 D: 假如在初始化的过程中文件不能打开或创建,将抛出IOException
- 3.1 下面是创建File对象的语句,错误的是( ) A: File f=new File("d:\\text.txt"); B: File f=new File("d: "); C: File f=new File("d:","text.txt"); D: File f=new File("d:\text.txt");