类 FileConfiguration
- 所有已实现的接口:
Configuration
,ConfigurationSection
- 直接已知子类:
YamlConfiguration
Configuration
的配置文件的基类-
字段概要
从类继承的字段 org.bukkit.configuration.MemoryConfiguration
defaults, options
从类继承的字段 org.bukkit.configuration.MemorySection
map
-
构造器概要
构造器说明创建一个空的,没有值默认值的FileConfiguration
.FileConfiguration
(@Nullable Configuration defaults) 创建一个空的FileConfiguration
并且使用Configuration
内的所有默认值创建它. -
方法概要
修饰符和类型方法说明已过时。This method only exists for backwards compatibility.void
从指定位置加载FileConfiguration
void
Loads thisFileConfiguration
from the specified reader.void
Loads thisFileConfiguration
from the specified location.abstract void
loadFromString
(@NotNull String contents) Loads thisFileConfiguration
from the specified string, as opposed to from file.options()
获取这个Configuration
的ConfigurationOptions
.void
以一个FileConfiguration
调用该方法,将文件储存到指定位置.void
以一个FileConfiguration
调用该方法,将文件储存到指定位置.将这个FileConfiguration
转化为String对象并且返回从类继承的方法 org.bukkit.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
从类继承的方法 org.bukkit.configuration.MemorySection
contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, setComments, setInlineComments, toString
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.bukkit.configuration.ConfigurationSection
contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, set, setComments, setInlineComments
-
构造器详细资料
-
FileConfiguration
public FileConfiguration()创建一个空的,没有值默认值的FileConfiguration
. -
FileConfiguration
创建一个空的FileConfiguration
并且使用Configuration
内的所有默认值创建它.- 参数:
defaults
- 为其创建提供缺省值的Configuration.
-
-
方法详细资料
-
save
以一个FileConfiguration
调用该方法,将文件储存到指定位置.如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常
本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存
- 参数:
file
- 要储存的文件- 抛出:
IOException
- 然后会给出无法创建或者保存的原因.IllegalArgumentException
- 如果文件为空,抛出该异常
-
save
以一个FileConfiguration
调用该方法,将文件储存到指定位置.如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常
本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存
- 参数:
file
- 要储存的文件- 抛出:
IOException
- 然后会给出无法创建或者保存的原因.IllegalArgumentException
- 如果文件为空,泡出该异常
-
saveToString
将这个FileConfiguration
转化为String对象并且返回- 返回:
- 这个FileConfiguration包含的所有String
-
load
public void load(@NotNull @NotNull File file) throws FileNotFoundException, IOException, InvalidConfigurationException 从指定位置加载FileConfiguration
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
- File to load from.- 抛出:
FileNotFoundException
- Thrown when the given file cannot be opened.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.IllegalArgumentException
- Thrown when file is null.
-
load
Loads thisFileConfiguration
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
- the reader to load from- 抛出:
IOException
- thrown when underlying reader throws an IOExceptionInvalidConfigurationException
- thrown when the reader does not represent a valid ConfigurationIllegalArgumentException
- thrown when reader is null
-
load
public void load(@NotNull @NotNull String file) throws FileNotFoundException, IOException, InvalidConfigurationException Loads thisFileConfiguration
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
- File to load from.- 抛出:
FileNotFoundException
- Thrown when the given file cannot be opened.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.IllegalArgumentException
- Thrown when file is null.
-
loadFromString
public abstract void loadFromString(@NotNull @NotNull String contents) throws InvalidConfigurationException Loads thisFileConfiguration
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
- Contents of a Configuration to load.- 抛出:
InvalidConfigurationException
- Thrown if the specified string is invalid.IllegalArgumentException
- Thrown if contents is null.
-
buildHeader
已过时。This method only exists for backwards compatibility. It will do nothing and should not be used! Please useFileConfigurationOptions.getHeader()
instead.- 返回:
- 空白字符串
-
options
从接口复制的说明:Configuration
获取这个Configuration
的ConfigurationOptions
.如需修改配置,直接修改返回值即可.
原文: Gets the
ConfigurationOptions
for thisConfiguration
.All setters through this method are chainable.
- 指定者:
options
在接口中Configuration
- 覆盖:
options
在类中MemoryConfiguration
- 返回:
- 这个配置文件的一些配置(格式之类的).
-