@Test(expected = FileNotFoundException.class) public void testGetResourcesFileNotFoundNull() throws FileNotFoundException { PropertiesUtils.getResourceFile(null); fail(ResourcesPublicUtilTest.EXPECTING_EXCEPTION_FILE_NOT_FOUND_EXCEPTION); }
public static File getResourceFile(String resourcesFile) throws FileNotFoundException { if (resourcesFile == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } URL url; try { url = PropertiesUtils.class.getClassLoader().getResource(resourcesFile); } catch (final SecurityException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); } if (url == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } File file; try { file = new File(url.toURI()); } catch (final URISyntaxException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); file = new File(url.getFile().replaceAll("%20", " ")); } if (file.exists()) { return file; } throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); }
PropertiesUtils { public static File getResourceFile(String resourcesFile) throws FileNotFoundException { if (resourcesFile == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } URL url; try { url = PropertiesUtils.class.getClassLoader().getResource(resourcesFile); } catch (final SecurityException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); } if (url == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } File file; try { file = new File(url.toURI()); } catch (final URISyntaxException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); file = new File(url.getFile().replaceAll("%20", " ")); } if (file.exists()) { return file; } throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } }
PropertiesUtils { public static File getResourceFile(String resourcesFile) throws FileNotFoundException { if (resourcesFile == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } URL url; try { url = PropertiesUtils.class.getClassLoader().getResource(resourcesFile); } catch (final SecurityException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); } if (url == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } File file; try { file = new File(url.toURI()); } catch (final URISyntaxException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); file = new File(url.getFile().replaceAll("%20", " ")); } if (file.exists()) { return file; } throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } private  PropertiesUtils(); }
PropertiesUtils { public static File getResourceFile(String resourcesFile) throws FileNotFoundException { if (resourcesFile == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } URL url; try { url = PropertiesUtils.class.getClassLoader().getResource(resourcesFile); } catch (final SecurityException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); } if (url == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } File file; try { file = new File(url.toURI()); } catch (final URISyntaxException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); file = new File(url.getFile().replaceAll("%20", " ")); } if (file.exists()) { return file; } throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } private  PropertiesUtils(); static InputStream getConfigAsStream(String resourcesFile); static InputStream getResourceAsStream(String resourcesFile); static File getResourceFile(String resourcesFile); static Path getResourcePath(String resourcesFile); static Stream<String> getResourceListing(Class clazz, String path); static File findFile(String filename); static File fileFromConfigFolder(String subpath); static File fileFromDataFolder(String subpath); static File fileFromTmpFolder(String subpath); static Properties readProperties(File propertiesFile); static C readYaml(File yamlFile, Class<C> clasz); static C readYaml(File yamlFile, TypeReference<C> typeReference); static C readYaml(InputStream yamlInputStream, Class<C> clasz); static C readYaml(Path yamlPath, Class<C> clasz); static void writeYaml(File destination, Object config); static String getResourceAsString(String resourcesFile); }
PropertiesUtils { public static File getResourceFile(String resourcesFile) throws FileNotFoundException { if (resourcesFile == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } URL url; try { url = PropertiesUtils.class.getClassLoader().getResource(resourcesFile); } catch (final SecurityException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); } if (url == null) { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } File file; try { file = new File(url.toURI()); } catch (final URISyntaxException e) { SysErrLogger.FAKE_LOGGER.ignoreLog(e); file = new File(url.getFile().replaceAll("%20", " ")); } if (file.exists()) { return file; } throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } private  PropertiesUtils(); static InputStream getConfigAsStream(String resourcesFile); static InputStream getResourceAsStream(String resourcesFile); static File getResourceFile(String resourcesFile); static Path getResourcePath(String resourcesFile); static Stream<String> getResourceListing(Class clazz, String path); static File findFile(String filename); static File fileFromConfigFolder(String subpath); static File fileFromDataFolder(String subpath); static File fileFromTmpFolder(String subpath); static Properties readProperties(File propertiesFile); static C readYaml(File yamlFile, Class<C> clasz); static C readYaml(File yamlFile, TypeReference<C> typeReference); static C readYaml(InputStream yamlInputStream, Class<C> clasz); static C readYaml(Path yamlPath, Class<C> clasz); static void writeYaml(File destination, Object config); static String getResourceAsString(String resourcesFile);  }