下列__________说法是正确的?I:File file = new File("input.txt");try (Scanner input = new Scanner(file)) { String line = input.nextLine();}II:try (File file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine();}III:File file;try (file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine();}IV:File file;Scanner input;try (file = new File("input.txt"); input = new Scanner(file);) { String line = input.nextLine();}
A: I
B: II
C: III
D: IV
A: I
B: II
C: III
D: IV
举一反三
- 下列语句( )能够正确实例化Scanner类的对象,用于获得键盘输入的数据。 A: Scanner input=new Scanner(System.out); B: Scanner input=new Scanner(System.in); C: Scanner input=new Scanner(System); D: Scanner input=new Scanner();
- 以下哪种方式可以允许上传图片格式文件?( )。 A: <;input type=”file” accept=”image/*” />; B: <;input type=”file” accept=”text/css” />; C: <;input type=”file” accept=”application/rtf” />; D: <;input type=”file” accept=”video/mpeg” />;
- 创建一个d盘aa文件夹下news.txt文件对象,以下正确的是 A: File file = new File("d:/aa"); B: File file = new File("d:/aa/news.txt"); C: File file = new File("d:/news.txt"); D: File file = new File("d:\aa\news.txt");
- 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");
- 下列写法错误的是 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 ("."));