@Test @DisplayName("Try to check for resources in a text file") void resourceExists_2() { assertThrows(IOException.class, () -> resourceExists(Paths.get("src/test/resources/small_file.txt"), "META-INF/MANIFEST.MF")); }
public static boolean resourceExists(Path file, String resource) throws IOException { checkNotNull(resource); checkNotNull(file); if (!Files.exists(file)) throw new FileNotFoundException(); if (!resource.startsWith("/")) resource = "/" + resource; try (FileSystem fs = FileSystems.newFileSystem(file, (ClassLoader) null)) { return Files.exists(fs.getPath(resource)); } catch (ProviderNotFoundException e) { throw new IOException("Illegal file type"); } }
JarUtil { public static boolean resourceExists(Path file, String resource) throws IOException { checkNotNull(resource); checkNotNull(file); if (!Files.exists(file)) throw new FileNotFoundException(); if (!resource.startsWith("/")) resource = "/" + resource; try (FileSystem fs = FileSystems.newFileSystem(file, (ClassLoader) null)) { return Files.exists(fs.getPath(resource)); } catch (ProviderNotFoundException e) { throw new IOException("Illegal file type"); } } }
JarUtil { public static boolean resourceExists(Path file, String resource) throws IOException { checkNotNull(resource); checkNotNull(file); if (!Files.exists(file)) throw new FileNotFoundException(); if (!resource.startsWith("/")) resource = "/" + resource; try (FileSystem fs = FileSystems.newFileSystem(file, (ClassLoader) null)) { return Files.exists(fs.getPath(resource)); } catch (ProviderNotFoundException e) { throw new IOException("Illegal file type"); } } private  JarUtil(); }
JarUtil { public static boolean resourceExists(Path file, String resource) throws IOException { checkNotNull(resource); checkNotNull(file); if (!Files.exists(file)) throw new FileNotFoundException(); if (!resource.startsWith("/")) resource = "/" + resource; try (FileSystem fs = FileSystems.newFileSystem(file, (ClassLoader) null)) { return Files.exists(fs.getPath(resource)); } catch (ProviderNotFoundException e) { throw new IOException("Illegal file type"); } } private  JarUtil(); static Optional<String> getManifestValue(Path file, String attribute); static Optional<String> getManifestValue(File file, String attribute); static Attributes getManifest(Path file); static Attributes getManifest(File file); static long getResourceSize(Path file, String resource); static long getResourceSize(File file, String resource); static URL getResourceUrl(Path file, String resource); static boolean resourceExists(Path file, String resource); }
JarUtil { public static boolean resourceExists(Path file, String resource) throws IOException { checkNotNull(resource); checkNotNull(file); if (!Files.exists(file)) throw new FileNotFoundException(); if (!resource.startsWith("/")) resource = "/" + resource; try (FileSystem fs = FileSystems.newFileSystem(file, (ClassLoader) null)) { return Files.exists(fs.getPath(resource)); } catch (ProviderNotFoundException e) { throw new IOException("Illegal file type"); } } private  JarUtil(); static Optional<String> getManifestValue(Path file, String attribute); static Optional<String> getManifestValue(File file, String attribute); static Attributes getManifest(Path file); static Attributes getManifest(File file); static long getResourceSize(Path file, String resource); static long getResourceSize(File file, String resource); static URL getResourceUrl(Path file, String resource); static boolean resourceExists(Path file, String resource);  }