类 FileConfiguration

所有已实现的接口:
Configuration, ConfigurationSection
直接已知子类:
YamlConfiguration

public abstract class FileConfiguration extends MemoryConfiguration
这是一个实现了 Configuration 的配置文件的基类
  • 构造器详细资料

  • 方法详细资料

    • save

      public void save(@NotNull @NotNull File file) throws IOException
      以一个 FileConfiguration 调用该方法,将文件储存到指定位置.

      如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常

      本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存

      参数:
      file - 要储存的文件
      抛出:
      IOException - 然后会给出无法创建或者保存的原因.
      IllegalArgumentException - 如果文件为空,抛出该异常
    • save

      public void save(@NotNull @NotNull String file) throws IOException
      以一个 FileConfiguration 调用该方法,将文件储存到指定位置.

      如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常

      本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存

      参数:
      file - 要储存的文件
      抛出:
      IOException - 然后会给出无法创建或者保存的原因.
      IllegalArgumentException - 如果文件为空,泡出该异常
    • saveToString

      @NotNull public abstract @NotNull String saveToString()
      将这个 FileConfiguration 转化为String对象并且返回
      返回:
      这个FileConfiguration包含的所有String
    • load

      从指定位置加载 FileConfiguration.

      此配置中包含的所有值都将被移除,只保留设置和默认值,新的值将从给定的文件中加载.

      如果文件因任何原因无法加载,将会抛出异常.

      原文:Load from the specified file. All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file. If the file cannot be loaded for any reason, an exception will be thrown.

      参数:
      file - 要加载的文件
      抛出:
      FileNotFoundException - 当给定的文件无法被打开时抛出
      IOException - 当给定的文件无法被读取时抛出
      InvalidConfigurationException - 当给定的文件不是有效的配置时抛出
      IllegalArgumentException - 当文件为null时抛出
    • load

      从指定的读取器加载此 FileConfiguration.

      此配置中包含的所有值都将被移除,只保留设置和默认值,新的值将从给定的流中加载.

      原文:Loads this FileConfiguration from the specified reader. All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.

      参数:
      reader - 要从中加载的读取器
      抛出:
      IOException - 当底层读取器抛出IOException时抛出
      InvalidConfigurationException - 当读取器不表示有效的配置时抛出
      IllegalArgumentException - 当reader为null时抛出
    • load

      从指定位置加载 FileConfiguration.

      此配置中包含的所有值都将被移除,只保留设置和默认值,新的值将从给定的文件中加载.

      如果文件因任何原因无法加载,将会抛出异常.

      原文:Loads this FileConfiguration from the specified location. All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file. If the file cannot be loaded for any reason, an exception will be thrown.

      参数:
      file - 要加载的文件
      抛出:
      FileNotFoundException - 当给定的文件无法被打开时抛出
      IOException - 当给定的文件无法被读取时抛出
      InvalidConfigurationException - 当给定的文件不是有效的配置时抛出
      IllegalArgumentException - 当文件为null时抛出
    • loadFromString

      public abstract void loadFromString(@NotNull @NotNull String contents) throws InvalidConfigurationException
      从指定的字符串加载此 FileConfiguration,而不是从文件加载.

      此配置中包含的所有值都将被移除,只保留设置和默认值,新的值将从给定的字符串中加载.

      如果字符串在任何方面无效,将会抛出异常.

      原文:Loads this FileConfiguration from the specified string, as opposed to from file. All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given string. If the string is invalid in any way, an exception will be thrown.

      参数:
      contents - 要加载的配置内容
      抛出:
      InvalidConfigurationException - 如果指定的字符串无效则抛出
      IllegalArgumentException - 如果contents为null则抛出
    • buildHeader

      @NotNull @Deprecated(since="1.18.1") protected @NotNull String buildHeader()
      已过时。
      此方法仅为向后兼容而存在.它不会执行任何操作,请勿使用!请使用 FileConfigurationOptions.getHeader() 代替.
      返回:
      空白字符串
    • options

      从接口复制的说明: Configuration
      获取这个 Configuration 的 ConfigurationOptions.

      如需修改配置,直接修改返回值即可.

      原文: Gets the ConfigurationOptions for this Configuration.

      All setters through this method are chainable.

      指定者:
      options 在接口中 Configuration
      覆盖:
      options 在类中 MemoryConfiguration
      返回:
      这个配置文件的一些配置(格式之类的).