VirtualDirTgz extends VirtualDir { @Override public void finalize() throws Throwable { super.finalize(); close(); } VirtualDirTgz(File tgz); @Override String getBasePath(); @Override File getBaseFile(); @Override InputStream getInputStream(String path); @Override File getFile(String path); @Override String[] list(String path); @Override boolean exists(String path); @Override String[] listAllFiles(); @Override void close(); @Override boolean isCompressed(); @Override boolean isArchive(); @Override void finalize(); @Override File getTempDir();  }
@Test public void testFinalize() throws Throwable { final File testTgz = TestUtil.getTestFile("tgz/test-archive.tgz"); virtualDir = new VirtualDirTgz(testTgz); assertExpectedFile("test-archive/dir1/file3.txt"); final File tempDir = virtualDir.getTempDir(); assertNotNull(tempDir); assertTrue(tempDir.isDirectory()); virtualDir.finalize(); assertFalse(tempDir.isDirectory()); }