@Test void testGetResource2() { JarResource resource = new JarResource(); assertThrows(NullPointerException.class, () -> resource.getResource("we_wont_find_this")); }
@Override public URL getResource(String location) { URL result = null; if (location != null) { try { try (JarFile jar = new JarFile(jarFile)) { if (jar.getJarEntry(location) != null) { result = new URL("jar:" + jarFile.toURI() + "!/" + location); } } } catch (IOException ioe) { result = null; } } return result; }
JarResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null) { try { try (JarFile jar = new JarFile(jarFile)) { if (jar.getJarEntry(location) != null) { result = new URL("jar:" + jarFile.toURI() + "!/" + location); } } } catch (IOException ioe) { result = null; } } return result; } }
JarResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null) { try { try (JarFile jar = new JarFile(jarFile)) { if (jar.getJarEntry(location) != null) { result = new URL("jar:" + jarFile.toURI() + "!/" + location); } } } catch (IOException ioe) { result = null; } } return result; } JarResource();  JarResource(File jarFile); }
JarResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null) { try { try (JarFile jar = new JarFile(jarFile)) { if (jar.getJarEntry(location) != null) { result = new URL("jar:" + jarFile.toURI() + "!/" + location); } } } catch (IOException ioe) { result = null; } } return result; } JarResource();  JarResource(File jarFile); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location); @Override Stream<String> getAllLocations(); File getJarFile(); void setJarFile(File jarFile); }
JarResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null) { try { try (JarFile jar = new JarFile(jarFile)) { if (jar.getJarEntry(location) != null) { result = new URL("jar:" + jarFile.toURI() + "!/" + location); } } } catch (IOException ioe) { result = null; } } return result; } JarResource();  JarResource(File jarFile); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location); @Override Stream<String> getAllLocations(); File getJarFile(); void setJarFile(File jarFile);  }