@Test public void testGetClasspathResource() throws Exception { Path classpathResource = ResourceHelper.getClasspathResource(this.getClass(), "classpath-resource.file", "no exception wanted!"); assertTrue(Files.exists(classpathResource)); assertEquals(FileUtils.readFileToString(classpathResource.toFile()), "test-file-content"); }
public static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage) throws NoSuchFileException { try { return Paths.get(classDef.getResource(classPathResource).toURI()); } catch (FileSystemNotFoundException | URISyntaxException | NullPointerException e) { NoSuchFileException exc = new NoSuchFileException(classPathResource, null, exceptionMessage); exc.addSuppressed(e); throw exc; } }
ResourceHelper { public static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage) throws NoSuchFileException { try { return Paths.get(classDef.getResource(classPathResource).toURI()); } catch (FileSystemNotFoundException | URISyntaxException | NullPointerException e) { NoSuchFileException exc = new NoSuchFileException(classPathResource, null, exceptionMessage); exc.addSuppressed(e); throw exc; } } }
ResourceHelper { public static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage) throws NoSuchFileException { try { return Paths.get(classDef.getResource(classPathResource).toURI()); } catch (FileSystemNotFoundException | URISyntaxException | NullPointerException e) { NoSuchFileException exc = new NoSuchFileException(classPathResource, null, exceptionMessage); exc.addSuppressed(e); throw exc; } }  }
ResourceHelper { public static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage) throws NoSuchFileException { try { return Paths.get(classDef.getResource(classPathResource).toURI()); } catch (FileSystemNotFoundException | URISyntaxException | NullPointerException e) { NoSuchFileException exc = new NoSuchFileException(classPathResource, null, exceptionMessage); exc.addSuppressed(e); throw exc; } }  static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage); static String getClasspathResourceAsStream(Class<?> classDef, String classPathResource); }
ResourceHelper { public static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage) throws NoSuchFileException { try { return Paths.get(classDef.getResource(classPathResource).toURI()); } catch (FileSystemNotFoundException | URISyntaxException | NullPointerException e) { NoSuchFileException exc = new NoSuchFileException(classPathResource, null, exceptionMessage); exc.addSuppressed(e); throw exc; } }  static Path getClasspathResource(Class<?> classDef, String classPathResource, String exceptionMessage); static String getClasspathResourceAsStream(Class<?> classDef, String classPathResource);  }