Java IO Serialization

© examsiri.com
Question : 9 of 17
 
Marks: +1, -0
The doesFileExist method takes an array of directory names representing a path from the root file system and a file name. The method returns true if the file exists, false if it does not.
Place the code fragments in position to complete this method.
public static boolean doesFileExist(String[] directories, String filename) {
(1)_______
  for (String dir : directories ) {
   (2)_______
  }
(3)_______
(4)_______
}

Code Fragments
path = path.getSubdirectory(dir);
String path = "";
return file.exists();
path = new File(path, dir);
return ! file.isNew();
path = path.getFile(filename);
returnpath.isFile();
File path = new File(File.separator);
return(file ! = null);
File path = new File("");
File file = new File(path, filename);
path = path + File.separator + dir;
Go to Question: