在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);
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);
举一反三
- 在下列Java代码中,会出现编译错误的是( )。 A: File f=new File(“/”,”1.dat”); B: DataInputStream din=new DataInputStream(new FileInputStream(“1.dat”) ); C: InputStreamReader in=new InputStreamReader(System.in); D: OutputStreamWriter out=new OutputStreamWriter(System.in);
- 要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( ) 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");
- 在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: 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 ("."));