@Test void loadExistingPropertiesFromFile(TemporaryFolder temporaryFolder) throws IOException { File propertiesFile = new File(temporaryFolder.getRoot(), "static.properties"); Properties staticProps = new OrderedProperties(); staticProps.setProperty("my.name", "static value"); staticProps.setProperty("another", "another static value"); try (OutputStream outputStream = new StripFirstLineStream(new FileOutputStream(propertiesFile))) { staticProps.store(outputStream, null); } Properties properties = loadExistingProperties(propertiesFile); assertTrue(properties.containsKey("my.name")); assertTrue(properties.containsKey("another")); }
@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);  }