在下列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: 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);
举一反三
- 在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);
- 在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");
- 下面创建的输入或输出流对象哪个能读或写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”));
- 要读一个较大的文件,下列创建对象的方法中哪个是最合适的?( ) 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: 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 ("."));