@Test void loadFileFailure(TemporaryFolder temporaryFolder) throws IOException { if (!POSIX_ENABLED) { return; } File file = new File(temporaryFolder.getRoot(), "static.properties"); FileUtils.touch(file); Files.setPosixFilePermissions(file.toPath(), PosixFilePermissions.fromString("---------")); assertThrows(PropertyFileException.class, () -> loadExistingProperties(file)); Files.setPosixFilePermissions(file.toPath(), PosixFilePermissions.fromString("rwxrwxrwx")); Files.delete(file.toPath()); }
@NotNull public static Properties loadExistingProperties(File propertiesFile) { Properties properties = new OrderedProperties(); if (propertiesFile.exists()) { try (InputStream stream = Files.newInputStream(propertiesFile.toPath())) { properties.load(stream); } catch (IOException e) { throw new PropertyFileException("Exception reading existing contents from " + propertiesFile.getName() + " file", e); } } return properties; }
PropertyFileUtils { @NotNull public static Properties loadExistingProperties(File propertiesFile) { Properties properties = new OrderedProperties(); if (propertiesFile.exists()) { try (InputStream stream = Files.newInputStream(propertiesFile.toPath())) { properties.load(stream); } catch (IOException e) { throw new PropertyFileException("Exception reading existing contents from " + propertiesFile.getName() + " file", e); } } return properties; } }
PropertyFileUtils { @NotNull public static Properties loadExistingProperties(File propertiesFile) { Properties properties = new OrderedProperties(); if (propertiesFile.exists()) { try (InputStream stream = Files.newInputStream(propertiesFile.toPath())) { properties.load(stream); } catch (IOException e) { throw new PropertyFileException("Exception reading existing contents from " + propertiesFile.getName() + " file", e); } } return properties; } private  PropertyFileUtils(); }
PropertyFileUtils { @NotNull public static Properties loadExistingProperties(File propertiesFile) { Properties properties = new OrderedProperties(); if (propertiesFile.exists()) { try (InputStream stream = Files.newInputStream(propertiesFile.toPath())) { properties.load(stream); } catch (IOException e) { throw new PropertyFileException("Exception reading existing contents from " + propertiesFile.getName() + " file", e); } } return properties; } private  PropertyFileUtils(); @NotNull static Properties loadExistingProperties(File propertiesFile); }
PropertyFileUtils { @NotNull public static Properties loadExistingProperties(File propertiesFile) { Properties properties = new OrderedProperties(); if (propertiesFile.exists()) { try (InputStream stream = Files.newInputStream(propertiesFile.toPath())) { properties.load(stream); } catch (IOException e) { throw new PropertyFileException("Exception reading existing contents from " + propertiesFile.getName() + " file", e); } } return properties; } private  PropertyFileUtils(); @NotNull static Properties loadExistingProperties(File propertiesFile);  }