@Test public void findArchiveRoot() throws URISyntaxException, IOException { URL resource = getClass().getResource("archive.zip"); URI localDatasetURIRoot = DatasetFinderUtil.getLocalDatasetURIRoot(new File(resource.toURI())); assertThat(localDatasetURIRoot.toString(), endsWith("/archive.zip!/template-dataset-e68f4487ebc3bc70668c0f738223b92da0598c00/")); }
public static URI getLocalDatasetURIRoot(File localDatasetURI) throws IOException { try (ZipFile zipFile = new ZipFile(localDatasetURI)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); String archiveRoot = null; while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { archiveRoot = entry.getName(); break; } } return URI.create("jar:" + localDatasetURI.toURI() + "!/" + archiveRoot); } }
DatasetFinderUtil { public static URI getLocalDatasetURIRoot(File localDatasetURI) throws IOException { try (ZipFile zipFile = new ZipFile(localDatasetURI)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); String archiveRoot = null; while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { archiveRoot = entry.getName(); break; } } return URI.create("jar:" + localDatasetURI.toURI() + "!/" + archiveRoot); } } }
DatasetFinderUtil { public static URI getLocalDatasetURIRoot(File localDatasetURI) throws IOException { try (ZipFile zipFile = new ZipFile(localDatasetURI)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); String archiveRoot = null; while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { archiveRoot = entry.getName(); break; } } return URI.create("jar:" + localDatasetURI.toURI() + "!/" + archiveRoot); } }  }
DatasetFinderUtil { public static URI getLocalDatasetURIRoot(File localDatasetURI) throws IOException { try (ZipFile zipFile = new ZipFile(localDatasetURI)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); String archiveRoot = null; while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { archiveRoot = entry.getName(); break; } } return URI.create("jar:" + localDatasetURI.toURI() + "!/" + archiveRoot); } }  static URI getLocalDatasetURIRoot(File localDatasetURI); static String getLocalDatasetURIRoot(InputStream zipStream); }
DatasetFinderUtil { public static URI getLocalDatasetURIRoot(File localDatasetURI) throws IOException { try (ZipFile zipFile = new ZipFile(localDatasetURI)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); String archiveRoot = null; while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { archiveRoot = entry.getName(); break; } } return URI.create("jar:" + localDatasetURI.toURI() + "!/" + archiveRoot); } }  static URI getLocalDatasetURIRoot(File localDatasetURI); static String getLocalDatasetURIRoot(InputStream zipStream);  }