YamlFile extends YamlConfiguration implements Commentable { public static YamlFile loadConfiguration(final File file, boolean withComments) { Validate.notNull(file, "File cannot be null"); return load(config -> { config.setConfigurationFile(file); config.load(); }, withComments); } YamlFile();  YamlFile(final String path);  YamlFile(final File file);  YamlFile(final URI uri);  YamlFile(final URL url); void save(); String saveToString(); @Override void setComment(final String path, final String comment, final CommentType type); @Override String getComment(final String path, final CommentType type); void load(); void loadWithComments(); @Override void loadFromString(final String contents); void createOrLoad(); void createOrLoadWithComments(); boolean exists(); void createNewFile(final boolean overwrite); void deleteFile(); long getSize(); String getFilePath(); File getConfigurationFile(); void setConfigurationFile(final String path); void setConfigurationFile(final URI uri); void setConfigurationFile(final File file); File copyTo(final String path); void copyTo(final File file); String fileToString(); @Override String toString(); static YamlFile loadConfiguration(final File file, boolean withComments); static YamlFile loadConfiguration(final File file); static YamlFile loadConfiguration(final InputStream stream, boolean withComments); static YamlFile loadConfiguration(final InputStream stream); static YamlFile loadConfiguration(final Reader reader, boolean withComments); static YamlFile loadConfiguration(final Reader reader);  }
@Test void loadConfiguration() throws Exception { YamlFile yamlFile = YamlFile.loadConfiguration(new File(YamlFileTest.getResourceURI("test.yml"))); final String content = "test:\n" + " number: 5\n" + " string: Hello world\n" + " boolean: true\n" + " list:\n" + " - Each\n" + " - word\n" + " - will\n" + " - be\n" + " - in\n" + " - a\n" + " - separated\n" + " - entry\n" + "math:\n" + " pi: 3.141592653589793\n" + "timestamp:\n" + " canonicalDate: 2020-07-04T13:18:04.458Z\n" + " formattedDate: 04/07/2020 15:18:04\n"; MatcherAssert.assertThat( "Couldn't load the file!", yamlFile.saveToString(), new IsEqual<>(content) ); yamlFile = YamlFile.loadConfiguration(new InputStreamOf(YamlFileTest.getResourceURI("test.yml"))); MatcherAssert.assertThat( "Couldn't load the file!", yamlFile.saveToString(), new IsEqual<>(content) ); yamlFile = YamlFile.loadConfiguration(new StringReader(content)); MatcherAssert.assertThat( "Couldn't load the file!", yamlFile.saveToString(), new IsEqual<>(content) ); }