YamlConfiguration extends FileConfiguration { @Override protected String buildHeader() { final String header = this.options().header(); final boolean copyHeader = this.options().copyHeader(); if (!copyHeader || header == null) { return ""; } final Configuration def = this.getDefaults(); if (def instanceof FileConfiguration) { final FileConfiguration filedefaults = (FileConfiguration) def; final String defaultsHeader = filedefaults.buildHeader(); if (defaultsHeader != null && defaultsHeader.length() > 0) { return defaultsHeader; } } final StringBuilder builder = new StringBuilder(); final String[] lines = header.split("\r?\n", -1); boolean startedHeader = false; for (int i = lines.length - 1; i >= 0; i--) { builder.insert(0, "\n"); if (startedHeader || lines[i].length() != 0) { builder.insert(0, lines[i]); startedHeader = true; } } return builder.toString(); }  static YamlConfiguration loadConfiguration(final File file); static YamlConfiguration loadConfiguration(final InputStream stream); static YamlConfiguration loadConfiguration(final Reader reader); @Override String saveToString(); @Override void loadFromString(final String contents); @Override YamlConfigurationOptions options();  }
@Test void buildHeader() { final InputStreamOf stream = new InputStreamOf( new ResourceOf("test.yml")); final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(stream); MatcherAssert.assertThat( "Couldn't build the header!", configuration.buildHeader(), new IsBlank() ); }