VirtualDir { public static VirtualDir create(File file) { String basePath = file.getPath(); boolean isZip; URI vdURI; try { URI uri = file.toURI(); if (file.isDirectory()) { isZip = false; vdURI = uri; } else if (file.getName().toLowerCase().endsWith(".zip")) { vdURI = ensureZipURI(uri); isZip = true; } else { return null; } Path virtualDirPath = getPathFromURI(vdURI); return new NIO(virtualDirPath, basePath, isZip, isZip, isZip); } catch (IOException e) { e.printStackTrace(); return null; } }  abstract String getBasePath(); Reader getReader(String path); abstract InputStream getInputStream(String path); abstract File getFile(String path); abstract String[] list(String path); abstract String[] listAllFiles(); abstract void close(); static VirtualDir create(File file); abstract boolean isCompressed(); abstract boolean isArchive(); File getTempDir(); @SuppressWarnings({"ResultOfMethodCallIgnored"}) static void deleteFileTree(File treeRoot); static File createUniqueTempDir();  }
@Test public void testNoZip() throws IOException { File file = getTestDataDir("VirtualDirTest.nozip"); VirtualDir virtualDir = VirtualDir.create(file); assertNull(virtualDir); }
@Test public void testNullArg() throws IOException { try { VirtualDir.create(null); fail("NullPointerException?"); } catch (NullPointerException e) { } }