/** * Open a classpath resource using the class loader of {@link IoSupport}. * * @see #openClassPathResource(String, Class) */ public static Option<InputStream> openClassPathResource(String resource) { return openClassPathResource(resource, IoSupport.class); }
/** Load a properties file from the classpath using the class loader of the given class. */ public static Properties loadPropertiesFromClassPath(final String resource, final Class<?> clazz) { for (InputStream in : openClassPathResource(resource, clazz)) { return withResource(in, new Function<InputStream, Properties>() { @Override public Properties apply(InputStream is) { final Properties p = new Properties(); try { p.load(is); } catch (Exception e) { throw new Error("Cannot load resource " + resource + "@" + clazz); } return p; } }); } return chuck(new FileNotFoundException(resource + " does not exist")); }