public abstract class FileConfiguration extends MemoryConfiguration
Configuration
的配置文件的基类defaults, options
map
构造器和说明 |
---|
FileConfiguration()
创建一个空的,没有值默认值的
FileConfiguration . |
FileConfiguration(Configuration defaults)
创建一个空的
FileConfiguration 并且使用 Configuration 内的所有默认值创建它. |
限定符和类型 | 方法和说明 |
---|---|
protected abstract java.lang.String |
buildHeader()
Compiles the header for this
FileConfiguration and returns the
result. |
void |
load(java.io.File file)
从指定位置加载
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. |
void |
load(java.io.Reader reader)
Loads this
FileConfiguration from the specified reader. |
void |
load(java.lang.String file)
Loads this
FileConfiguration from the specified location. |
abstract void |
loadFromString(java.lang.String contents)
Loads this
FileConfiguration from the specified string, as
opposed to from file. |
FileConfigurationOptions |
options()
获取这个
Configuration 的 ConfigurationOptions . |
void |
save(java.io.File file)
以一个
FileConfiguration 调用该方法,将文件储存到指定位置. |
void |
save(java.lang.String file)
以一个
FileConfiguration 调用该方法,将文件储存到指定位置. |
abstract java.lang.String |
saveToString()
将这个
FileConfiguration 转化为String对象并且返回 |
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isSet, isString, isVector, set
public FileConfiguration()
FileConfiguration
.public FileConfiguration(Configuration defaults)
FileConfiguration
并且使用 Configuration
内的所有默认值创建它.defaults
- 为其创建提供缺省值的Configuration.public void save(java.io.File file) throws java.io.IOException
FileConfiguration
调用该方法,将文件储存到指定位置.
如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常
本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存
file
- 要储存的文件java.io.IOException
- 然后会给出无法创建或者保存的原因.java.lang.IllegalArgumentException
- 如果文件为空,泡出该异常public void save(java.lang.String file) throws java.io.IOException
FileConfiguration
调用该方法,将文件储存到指定位置.
如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常
本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存
file
- 要储存的文件java.io.IOException
- 然后会给出无法创建或者保存的原因.java.lang.IllegalArgumentException
- 如果文件为空,泡出该异常public abstract java.lang.String saveToString()
FileConfiguration
转化为String对象并且返回public void load(java.io.File file) throws java.io.FileNotFoundException, java.io.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.java.io.FileNotFoundException
- Thrown when the given file cannot be
opened.java.io.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not
a valid Configuration.java.lang.IllegalArgumentException
- Thrown when file is null.public void load(java.io.Reader reader) throws java.io.IOException, InvalidConfigurationException
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
- the reader to load fromjava.io.IOException
- thrown when underlying reader throws an IOExceptionInvalidConfigurationException
- thrown when the reader does not
represent a valid Configurationjava.lang.IllegalArgumentException
- thrown when reader is nullpublic void load(java.lang.String file) throws java.io.FileNotFoundException, java.io.IOException, InvalidConfigurationException
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
- File to load from.java.io.FileNotFoundException
- Thrown when the given file cannot be
opened.java.io.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not
a valid Configuration.java.lang.IllegalArgumentException
- Thrown when file is null.public abstract void loadFromString(java.lang.String contents) throws InvalidConfigurationException
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
- Contents of a Configuration to load.InvalidConfigurationException
- Thrown if the specified string is
invalid.java.lang.IllegalArgumentException
- Thrown if contents is null.protected abstract java.lang.String buildHeader()
FileConfiguration
and returns the
result.
This will use the header from options()
-> FileConfigurationOptions.header()
, respecting the rules of FileConfigurationOptions.copyHeader()
if set.
public FileConfigurationOptions options()
Configuration
Configuration
的 ConfigurationOptions
.
如需修改配置,直接修改返回值即可.
原文:
Gets the ConfigurationOptions
for this Configuration
.
All setters through this method are chainable.
options
在接口中 Configuration
options
在类中 MemoryConfiguration