### Question:
FileUtil { public static String[] list(File dir) throws IOException { String[] fileNames = dir.list(); if(fileNames == null) { throw new IOException("Invalid directory or I/O error occurred for dir: " + dir.toString()); } return fileNames; }  static Path[] stat2Paths(FileStatus[] stats); static Path[] stat2Paths(FileStatus[] stats, Path path); static boolean fullyDelete(File dir); static boolean fullyDeleteContents(File dir); @Deprecated static void fullyDelete(FileSystem fs, Path dir); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path[] srcs, 
                             FileSystem dstFS, Path dst,
                             boolean deleteSource, 
                             boolean overwrite, Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             boolean overwrite,
                             Configuration conf); static boolean copyMerge(FileSystem srcFS, Path srcDir, 
                                  FileSystem dstFS, Path dstFile, 
                                  boolean deleteSource,
                                  Configuration conf, String addString); static boolean copy(File src,
                             FileSystem dstFS, Path dst,
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             File dst, boolean deleteSource,
                             Configuration conf); static String makeShellPath(String filename); static String makeShellPath(File file); static String makeShellPath(File file, boolean makeCanonicalPath); static long getDU(File dir); static void unZip(File inFile, File unzipDir); static void unTar(File inFile, File untarDir); static int symLink(String target, String linkname); static int chmod(String filename, String perm
                          ); static int chmod(String filename, String perm, boolean recursive); static final File createLocalTempFile(final File basefile,
                                               final String prefix,
                                               final boolean isDeleteOnExit); static void replaceFile(File src, File target); static File[] listFiles(File dir); static String[] list(File dir);  }### Answer:
@Test public void testListAPI() throws IOException { setupDirs(); String[] files = FileUtil.list(partitioned); Assert.assertEquals("Unexpected number of pre-existing files", 2, files.length); File newDir = new File(tmp.getPath(),"test"); newDir.mkdir(); Assert.assertTrue("Failed to create test dir", newDir.exists()); files = FileUtil.list(newDir); Assert.assertEquals("New directory unexpectedly contains files", 0, files.length); newDir.delete(); Assert.assertFalse("Failed to delete test dir", newDir.exists()); try { files = FileUtil.list(newDir); Assert.fail("IOException expected on list() for non-existent dir " + newDir.toString()); } catch(IOException ioe) { } }