要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( )
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”));
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中,以下代码()正确地创建了一个InputStreamReader类型的对象(选一项) A: new InputStreamReader(new FileInputStream("1.dat")); B: new InputStreamReader(new FileReader("1.dat")); C: new InputStreamReader(new BufferedReader("1.dat")); D: new InputStreamReader("1.dat");
- 如何用字母"new"来代替myfile文件中字母"old"?____ A: sed ‘s/old/new/g’ myfile>myfile B: sed ‘s/old/new’ <br/>myfile<br/>>myfile C: sed ‘1,$ s/old/new’ myfile>myfile D: sed ‘r/old/new’ myfile >myfile
- 下面创建的输入或输出流对象哪个能读或写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对象的语句是 ( ) 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)
- 在J2EE中,下面代码中,()不会编译错误。 A: File f = new File("/","autoexec.bat"); B: DataInputStream din = new DataInputStream(new FileInputStream("autoexec.bat")); C: InputStreamReader in = new InputStreamReader(System.in); D: OutputStreamWriter out = new OutputStreamWriter(System.in);