单选题The file “file.txt” exists on the file system and contsins ASCII text.  Given:   try {   File f = new File(“file.txt”);    OutputStream out = new FileOutputStream(f, true);   }    catch (IOException) {}   What is the result?()A The code does not compile.B The code runs and no change is made to the file.C The code runs and sets the length of the file to 0.D An exception is thrown because the file is not closed.E The code runs and deletes the file from the file system.

单选题
The file “file.txt” exists on the file system and contsins ASCII text.  Given:   try {   File f = new File(“file.txt”);    OutputStream out = new FileOutputStream(f, true);   }    catch (IOException) {}   What is the result?()
A

 The code does not compile.

B

 The code runs and no change is made to the file.

C

 The code runs and sets the length of the file to 0.

D

 An exception is thrown because the file is not closed.

E

 The code runs and deletes the file from the file system.


参考解析

解析: 暂无解析

相关考题:

下列InputStream构造方法正确的是()。 A、InputStream in=new FileReader(“file.txt”)B、InputStream in=new FileInputStream(“file.txt”)C、InputStream in=new InputStreamFileReader (“file.txt”,“read”)D、FileInputStream in=new FileReader(new File(“file.txt”))

要想以读方式打开文件“D:\File.txt”,以下不能实现目的的语句是()。A、ifstreaminf("D:\\FilEtxt",ios::in);B、ifstreaminf("D:\\File.txt");C、ofstreaminf("D:\\File.txt",ios::out);D、fstreaminf("D:\\File.txt",ios::in|ios::out);

WhichtwoconstructanOutputSreamthatappendstothefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”);B.OutputStreamout=newFileOutputStream(“file.txt”,“append”);C.FileOutputStreamout=newFileOutputStream(“file.txt”,true);D.FileOutputStreamout=newFileOutputStream(newfile(“file.txt”));E.OutputStreamout=newFileOutputStream(newFile(“file.txt”)true);

Whatwritesthetext“”totheendofthefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”); Out.writeBytes(“/n”);B.OutputStreamos=newFileOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);C.OutputStreamos=newFileOutputStream(“file.txt”); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);D.OutputStreamos=newOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);

Whichgetsthenameoftheparentdirectoryfile“file.txt”?() A.Stringname=File.getParentName(“file.txt”);B.Stringname=(newFile(“file.txt”)).getParent();C.Stringname=(newFile(“file.txt”)).getParentName();D.Stringname=(newFile(“file.txt”)).getParentFile();E.Directorydir=(newFile(“file.txt”)).getParentDir();Stringname=dir.getName();

Given that the current directory is empty, and that the user has read and write privileges to the current, and the following:Which statement is true?() A.Compilation fails.B.Nothing is added to the file system.C.Only a new file is created on the file system.D.Only a new directory is created on the file system.E.Both a new file and a new directory are created on the file system.

??有一台系统为Windows Server 2008的计算机,用户john属于本地组group1,管理员创建了一个文件file.txt,并设置本地组group1对file.txt具有完全控制权限,设置john对file.txt具有拒绝读取权限,最终john对file.txt具有()权限。A.完全控制B.读取C.拒绝读取D.读取和写入

字符串"a://xxk//file.txt"的长度为()。

对于如下程序:  #include    main( )  {    FILE *fp;    fp=fopen(“file.txt”,“w”);    fprintf(fp,“%s”,“xyz”);    fclose(fp);  }  若文件file.txt中原有的内容为good,则运行该程序以后,文件file.txt中的内容为()

Which two construct an OutputSream that appends to the file “file.txt”? ()A、 OutputStream out=new FileOutputStream(“file.txt”);B、 OutputStream out=new FileOutputStream(“file.txt”, “append”);C、 FileOutputStream out=new FileOutputStream(“file.txt”, true);D、 FileOutputStream out=new FileOutputStream(new file(“file.txt”));E、 OutputStream out=new FileOutputStream(new File(“file.txt”)true);

为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。A、File file 1=new File(“c://java//example//file.txt”)B、String path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)C、File dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)D、File file 1=new File(“c:/java//example/file.txt”)

Which of the following commands changes a file characteristic so that it cannot be seen with astandard directory query? ()A、attrib file.txt +hB、attrib file.txt +rC、ren file.txtD、attrib file.txt +s

Which command(s) will result in the smallest sized backup of the text files contained in the /staticFS filesystem?()  A、tar -cvf file_system.tar /staticFS ; gzip file_system.tarB、tar -xvf /staticFS file_system.tar ; gzip file_system.tarC、tar -cvf /staticFS file_system.tar ; compress file_system.tarD、tar -xvf file_system.tar /staticFS  ; compress file_system.tar

Which of the following will occur if an operator types the command vi file.out?()A、If the file exists it will be opened for editing. If the file does not exist an error message will be displayed.B、If the file exists it will be opened for editing. If the file does not exist a new file with the name file.out will be created and opened for editing.C、If the file exists an error message will be displayed. If the file does not exist a new file with the name file.out will be created and opened for editing.D、If the file exists the operator will be asked whether to open the file or overwrite the file. If the file does not exist a new file with the name file.out will be created and opened for editing.

Which determines if “prefs” is a directory and exists on the file system?()  A、 Boolean exists=Directory.exists (“prefs”);B、 Boolean exists=(new File(“prefs”)).isDir();C、 Boolean exists=(new Directory(“prefs”)).exists();D、 Boolean exists=(new File(“prefs”)).isDirectory();E、 Boolean exists=true;  Try{  Directory d = new Directory(“prefs”);  } catch (FileNotFoundException e) {  exists = false;  }

Which gets the name of the parent directory file “file.txt”?()A、 String name= File.getParentName(“file.txt”);B、 String name= (new File(“file.txt”)).getParent();C、 String name = (new File(“file.txt”)).getParentName();D、 String name= (new File(“file.txt”)).getParentFile();E、 Directory dir=(new File (“file.txt”)).getParentDir();  String name= dir.getName();

The file “file.txt” exists on the file system and contsins ASCII text.  Given:   try {   File f = new File(“file.txt”);    OutputStream out = new FileOutputStream(f, true);   }    catch (IOException) {}   What is the result?()A、 The code does not compile.B、 The code runs and no change is made to the file.C、 The code runs and sets the length of the file to 0.D、 An exception is thrown because the file is not closed.E、 The code runs and deletes the file from the file system.

单选题The file “file.txt” exists on the file system and contsins ASCII text.  Given:   try {   File f = new File(“file.txt”);    OutputStream out = new FileOutputStream(f, true);   }    catch (IOException) {}   What is the result?()A The code does not compile.B The code runs and no change is made to the file.C The code runs and sets the length of the file to 0.D An exception is thrown because the file is not closed.E The code runs and deletes the file from the file system.

单选题Which gets the name of the parent directory file “file.txt”?()A String name= File.getParentName(“file.txt”);B String name= (new File(“file.txt”)).getParent();C String name = (new File(“file.txt”)).getParentName();D String name= (new File(“file.txt”)).getParentFile();E Directory dir=(new File (“file.txt”)).getParentDir();  String name= dir.getName();

多选题Which two create an InputStream and open file the “file.txt” for reading? ()AInputStream in=new FileReader(“file.txt”);BInputStream in=new FileInputStream(“file.txt”);CInputStream in=new InputStreamFileReader (“file.txt”, “read”);DFileInputStream in=new FileReader(new File(“file.txt”));EFileInputStream in=new FileInputStream(new File(“file.txt”));

单选题Which determines if “prefs” is a directory and exists on the file system?()A Boolean exists=Directory.exists (“prefs”);B Boolean exists=(new File(“prefs”)).isDir();C Boolean exists=(new Directory(“prefs”)).exists();D Boolean exists=(new File(“prefs”)).isDirectory();E Boolean exists=true;  Try{  Directory d = new Directory(“prefs”);  } catch (FileNotFoundException e) {  exists = false;  }

单选题Which of the following will occur if an operator types the command vi file.out?()AIf the file exists it will be opened for editing. If the file does not exist an error message will be displayed.BIf the file exists it will be opened for editing. If the file does not exist a new file with the name file.out will be created and opened for editing.CIf the file exists an error message will be displayed. If the file does not exist a new file with the name file.out will be created and opened for editing.DIf the file exists the operator will be asked whether to open the file or overwrite the file. If the file does not exist a new file with the name file.out will be created and opened for editing.

填空题对于如下程序:  #include    main( )  {    FILE *fp;    fp=fopen(“file.txt”,“w”);    fprintf(fp,“%s”,“xyz”);    fclose(fp);  }  若文件file.txt中原有的内容为good,则运行该程序以后,文件file.txt中的内容为()

多选题创建一个向文件“file.txt”追加内容的输出流对象的语句有()。AFileOutputStream out=new FileOutputStream(“file.txt”,true);BOutputStream out=new FileOutputStream(“file.txt”,“append”);COutputStream out=new FileOutputStream(“file.txt”);DFileOutputStream out=new FileOutputStream(new file(“file.txt”));EOutputStream out=new FileOutputStream(new File(“file.txt”),true.;

多选题10. class MakeFile {  11. public static void main(String[] args) {  12. try {  13. File directory = new File(”d”);  14. File file = new File(directory,”f”);  15. if(!file.exists()) {  16. file.createNewFile();  17. }  18. } catch (IOException e) {  19. e.printStackTrace  20. }  21. }  22. }  The current directory does NOT contain a directory named “d.” Which three are true?()ALine 16 is never executed.BAn exception is thrown at runtime.CLine 13 creates a File object named “d”.DLine 14 creates a File object named “f‟.ELine 13 creates a directory named “d” in the file system.FLine 16 creates a directory named “d” and a file “f”  within it in the file system.GLine 14 creates a file named f inside of the directory named “d” in the file system.

单选题What writes the text “ ” to the end of the file “file.txt”?()A OutputStream out= new FileOutputStream (“file.txt”);   Out.writeBytes (“ /n”);B OutputStream os= new FileOutputStream (“file.txt”, true);   DataOutputStream out = new DataOutputStream(os);  out.writeBytes (“ /n”);C OutputStream os= new FileOutputStream (“file.txt”);   DataOutputStream out = new DataOutputStream(os);  out.writeBytes (“ /n”);D OutputStream os= new OutputStream (“file.txt”, true);   DataOutputStream out = new DataOutputStream(os);  out.writeBytes (“ /n”);

填空题字符串"a://xxk//file.txt"的长度为()。

多选题为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。AFile file 1=new File(“c://java//example//file.txt”)BString path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)CFile dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)DFile file 1=new File(“c:/java//example/file.txt”)