The code does not compile.
The code runs and no change is made to the file.
The code runs and sets the length of the file to 0.
An exception is thrown because the file is not closed.
The code runs and deletes the file from the file system.
第1题:
A.Compilation fails.
B.The file system has a new empty directory named dir.
C.The file system has a new empty directory named newDir.
D.The file system has a directory named dir, containing a file f1.txt.
E.The file system has a directory named newDir, containing a file f1.txt.
第2题:
创建一个向文件“file.txt”追加内容的输出流对象的语句有()。
第3题:
Which statements are true, given the code new FileOutputStream("data", true) for creating an object of class FileOutputStream?()
第4题:
Which of the following will occur if an operator types the command vi file.out?()
第5题:
Which determines if “prefs” is a directory and exists on the file system?()
第6题:
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?()
第7题:
What writes the text “ ” to the end of the file “file.txt”?()
第8题:
Implementation a.
Implementation b.
Implementation c.
Implementation d.
Implementation e.
第9题:
Boolean exists=Directory.exists (“prefs”);
Boolean exists=(new File(“prefs”)).isDir();
Boolean exists=(new Directory(“prefs”)).exists();
Boolean exists=(new File(“prefs”)).isDirectory();
Boolean exists=true; Try{ Directory d = new Directory(“prefs”); } catch (FileNotFoundException e) { exists = false; }
第10题:
FileOutputStream out=new FileOutputStream(“file.txt”,true);
OutputStream out=new FileOutputStream(“file.txt”,“append”);
OutputStream out=new FileOutputStream(“file.txt”);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”),true.;
第11题:
FileOutputStream has no constructors matching the given arguments.
An IOExeception will be thrown if a file named data already exists.
An IOExeception will be thrown if a file named data does not already exist.
If a file named data exists, its contents will be reset and overwritten.
If a file named data exists, output will be appended to its current contents.
第12题:
The code does not compile.
The code runs and no change is made to the file.
The code runs and sets the length of the file to 0.
An exception is thrown because the file is not closed.
The code runs and deletes the file from the file system.
第13题:
现有一个文件file21.txt,其内容是: abCdEf, 执行下列程序之后,输出的结果是______。 package ch1; import java,io.*; public class ex21 { static String name = "ch1\\file21.txt"; public static void main(String[] args) { try { readFile (); } catch(IOException ioe) { System.out.println(ioe.getMessage()); } } static void readFile () throws IOException { BufferedReader br = null; try { File f = new File(name); FileReader fr = new FileReader(f); br = new BufferedReader(fr); String str= br.readLine(); System.out.println(str.toLowerCase()); } finally if(br != null) br.close (); } } }
A.AbCdEf
B.abcdef
C.aBcDeF
D.ABCDEF
第14题:
Which two construct an OutputSream that appends to the file “file.txt”? ()
第15题:
为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。
第16题:
Which two create an InputStream and open file the “file.txt” for reading? ()
第17题:
Which gets the name of the parent directory file “file.txt”?()
第18题:
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?()
第19题:
If the file exists it will be opened for editing. If the file does not exist an error message will be displayed.
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.
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.
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.
第20题:
Line 16 is never executed.
An exception is thrown at runtime.
Line 13 creates a File object named “d”.
Line 14 creates a File object named “f‟.
Line 13 creates a directory named “d” in the file system.
Line 16 creates a directory named “d” and a file “f” within it in the file system.
Line 14 creates a file named f inside of the directory named “d” in the file system.
第21题:
OutputStream out= new FileOutputStream (“file.txt”); Out.writeBytes (“ /n”);
OutputStream os= new FileOutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
OutputStream os= new FileOutputStream (“file.txt”); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
OutputStream os= new OutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
第22题:
String name= File.getParentName(“file.txt”);
String name= (new File(“file.txt”)).getParent();
String name = (new File(“file.txt”)).getParentName();
String name= (new File(“file.txt”)).getParentFile();
Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
第23题:
OutputStream out=new FileOutputStream(“file.txt”);
OutputStream out=new FileOutputStream(“file.txt”, “append”);
FileOutputStream out=new FileOutputStream(“file.txt”, true);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”)true);
第24题:
File file 1=new File(“c://java//example//file.txt”)
String path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)
File dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)
File file 1=new File(“c:/java//example/file.txt”)