public abstract class FileConfiguration extends MemoryConfiguration implements LoadableConfiguration
Configuration
defaults, options
map
Constructor and Description |
---|
FileConfiguration()
Creates an empty
FileConfiguration with no default values. |
FileConfiguration(Configuration defaults)
Creates an empty
FileConfiguration using the specified
Configuration as a source for all default values. |
Modifier and Type | Method and Description |
---|---|
String |
buildHeader()
Compiles the header for this
FileConfiguration and returns the
result. |
void |
load(File file)
Loads this configuration from the specified file.
|
void |
load(InputStream stream)
Loads this configuration from the specified stream.
|
void |
load(Reader reader)
Loads this configuration from the specified reader.
|
void |
load(String file)
Loads this configuration from the specified file path.
|
FileConfigurationOptions |
options()
Gets the
ConfigurationOptions for this Configuration . |
void |
save(File file)
Saves this
FileConfiguration to the specified location. |
void |
save(String file)
Saves this
FileConfiguration to the specified location. |
void |
save(Writer writer)
Saves this configuration to a writer.
|
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isEmpty, isInt, isList, isLong, isPrimitiveWrapper, isSet, isString, mapChildrenKeys, mapChildrenValues, set, size, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
loadFromString, saveToString
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isEmpty, isInt, isList, isLong, isSet, isString, remove, set, size
public FileConfiguration()
FileConfiguration
with no default values.public FileConfiguration(Configuration defaults)
FileConfiguration
using the specified
Configuration
as a source for all default values.defaults
- Default value providerpublic void save(File file) throws IOException
FileConfiguration
to the specified location.
If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.
This method will use the options()
charset
encoding,
which defaults to UTF8.
file
- File to save to.IOException
- Thrown when the given file cannot be written to for any reason.IllegalArgumentException
- Thrown when file is null.public void save(String file) throws IOException
FileConfiguration
to the specified location.
If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.
This method will use the options()
charset
encoding,
which defaults to UTF8.
file
- File to save to.IOException
- Thrown when the given file cannot be written to for any reason.IllegalArgumentException
- Thrown when file is null.public void save(Writer writer) throws IOException
LoadableConfiguration
save
in interface LoadableConfiguration
writer
- where to save this configurationIOException
- when the contents cannot be written for any reason.public void load(String file) throws FileNotFoundException, IOException, InvalidConfigurationException
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.
This method will use the options()
charset
encoding,
which defaults to UTF8.
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.public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException
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.
This method will use the options()
charset
encoding,
which defaults to UTF8.
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.public void load(InputStream stream) throws IOException, InvalidConfigurationException
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.
If the file cannot be loaded for any reason, an exception will be thrown.
This method will use the options()
charset
encoding,
which defaults to UTF8.
stream
- Stream to load fromIOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.IllegalArgumentException
- Thrown when stream is null.load(Reader)
public void load(Reader reader) throws IOException, InvalidConfigurationException
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.
If the file cannot be loaded for any reason, an exception will be thrown.
load
in interface LoadableConfiguration
reader
- the reader to load fromIOException
- Thrown when underlying reader throws an IOException.InvalidConfigurationException
- Thrown when the reader does not represent a valid Configuration.IllegalArgumentException
- Thrown when reader is null.public FileConfigurationOptions options()
Configuration
ConfigurationOptions
for this Configuration
.
All setters through this method are chainable.
options
in interface Configuration
options
in class MemoryConfiguration
public String buildHeader()
FileConfiguration
and returns the
result.
This will use the header from options()
FileConfigurationOptions.header()
,
respecting the rules of FileConfigurationOptions.copyHeader()
and FileConfigurationOptions.headerFormatter()
if set.
Copyright © 2023. All rights reserved.