Class YamlFile
- All Implemented Interfaces:
Commentable,Configuration,ConfigurationSection,LoadableConfiguration
YamlConfiguration which saves all data in Yaml to a configuration file
with the added possibility to save and manage comments.
Note that this implementation is not synchronized.- Author:
- Carlos Lázaro Costa
-
Field Summary
Fields inherited from class org.simpleyaml.configuration.file.YamlConfiguration
yamlImplementationFields inherited from class org.simpleyaml.configuration.MemoryConfiguration
defaults, optionsFields inherited from class org.simpleyaml.configuration.MemorySection
map -
Constructor Summary
ConstructorsConstructorDescriptionYamlFile()Builds thisYamlFilewithout any configuration file.Builds thisFileConfigurationwith a source file.Builds thisFileConfigurationwith the file specified by path.Builds thisFileConfigurationwith the file specified by uri.Builds thisFileConfigurationwith the file specified by url.YamlFile(YamlImplementation yamlImplementation) Builds thisYamlFilewithout any configuration file. -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy this configuration file to another file, without deleting configuration file.Copy this configuration file to another path, without deleting configuration file.voidCreates a new empty file atomically for this configuration file if and only if it does not already exist.voidcreateNewFile(boolean overwrite) Creates a new empty file atomically for this configuration file.voidIf this configuration file does not exist then it is created along with missing parent directories.voidIf this configuration file does not exist then it is created along with missing parent directories.voidDeletes this configuration file from disk.booleanexists()Tests whether this configuration file exists.Returns a representation of the already saved configuration file.getComment(String path) Retrieve the block comment of the section or value selected by path.getComment(String path, CommentType type) Retrieve the comment of the section or value selected by path.getComment(String path, CommentType type, YamlCommentFormat yamlCommentFormat) Retrieve the comment of the section or value selected by path.getComment(String path, CommentType type, YamlCommentFormatter yamlCommentFormatter) Retrieve the comment of the section or value selected by path.getComment(String path, YamlCommentFormat yamlCommentFormat) Retrieve the block comment of the section or value selected by path.getComment(String path, YamlCommentFormatter yamlCommentFormatter) Retrieve the block comment of the section or value selected by path.Get the comment mapper.Returns this configuration file where data is located.Returns the absolute pathname string of this configuration file.Gets the footer of this configuration file.Gets the header of this configuration file.longgetSize()Returns the size of this configuration file.voidload()Loads configurations from this configuration file.voidload(SupplierIO.Reader readerSupplier) Loads thisYamlFilefrom the specified reader.static YamlFileloadConfiguration(File file) Creates a newYamlFile, loading from the given file (without comments).static YamlFileloadConfiguration(File file, boolean withComments) Creates a newYamlFile, loading from the given file.static YamlFileloadConfiguration(InputStream stream) Deprecated.static YamlFileloadConfiguration(InputStream stream, boolean withComments) Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.InputStream, boolean)static YamlFileloadConfiguration(Reader reader) Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.Reader)static YamlFileloadConfiguration(Reader reader, boolean withComments) Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.Reader, boolean)static YamlFileloadConfiguration(SupplierIO.InputStream streamSupplier) Creates a newYamlFile, loading from the given stream (without comments).static YamlFileloadConfiguration(SupplierIO.InputStream streamSupplier, boolean withComments) Creates a newYamlFile, loading from the given stream.static YamlFileloadConfiguration(SupplierIO.Reader readerSupplier) Creates a newYamlFile, loading from the given reader (without comments).static YamlFileloadConfiguration(SupplierIO.Reader readerSupplier, boolean withComments) Creates a newYamlFile, loading from the given reader.static YamlFileloadConfigurationFromString(String contents) Creates a newYamlFile, loading from the specified string contents (without comments).static YamlFileloadConfigurationFromString(String contents, boolean withComments) Creates a newYamlFile, loading from the specified string contents.voidLoads configurations from this configuration file including comments.Get a wrapper builder to set a value to the given path and optionally set comments.voidsave()Saves thisFileConfigurationto the configuration file location.Saves thisYamlFileto a string and returns it.voidSets the specified path to the given value.voidsetBlankLine(String path) Set a blank line at the beginning of the block comment.voidsetComment(String path, String comment) Set a block comment above the section or value selected by path.voidsetComment(String path, String comment, CommentType type) Set a comment to the section or value selected by path.voidsetComment(String path, String comment, CommentType type, YamlCommentFormat yamlCommentFormat) Set a comment to the section or value selected by path.voidsetComment(String path, String comment, CommentType type, YamlCommentFormatter yamlCommentFormatter) Set a comment to the section or value selected by path.voidsetComment(String path, String comment, YamlCommentFormat yamlCommentFormat) Set a block comment to the section or value selected by path.voidsetComment(String path, String comment, YamlCommentFormatter yamlCommentFormatter) Set a block comment to the section or value selected by path.voidsetCommentFormat(YamlCommentFormat yamlCommentFormat) Change the comment formatter to one of the defaults provided byYamlCommentFormat.voidsetCommentFormat(YamlCommentFormatter yamlCommentFormatter) Change the comment formatter for parsing and dumping comments.voidsetConfigurationFile(File file) Rebuilds thisFileConfigurationwith a source file.voidsetConfigurationFile(String path) Rebuilds thisFileConfigurationwith the file specified by path.voidsetConfigurationFile(URI uri) Rebuilds thisFileConfigurationwith the file specified by uri.voidSets the footer of this configuration file.voidSets the header that will be applied to the top of the saved output.protected voidsetListNode(Collection<?> value, KeyTree.Node node) toString()Returns a representation of this configuration file.Methods inherited from class org.simpleyaml.configuration.file.YamlConfiguration
dump, dump, get, getImplementation, load, load, load, load, loadFromString, loadHeader, options, save, set, setImplementationMethods inherited from class org.simpleyaml.configuration.file.FileConfiguration
buildHeader, load, save, saveMethods inherited from class org.simpleyaml.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaultsMethods inherited from class org.simpleyaml.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getCharacter, getCharacter, getCharacterList, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isCharacter, isConfigurationSection, isDouble, isEmpty, isFloat, isInt, isList, isLong, isPrimitiveWrapper, isSet, isShort, isString, mapChildrenKeys, mapChildrenValues, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.simpleyaml.configuration.ConfigurationSection
contains, createSection, createSection, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getCharacter, getCharacter, getCharacterList, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isCharacter, isConfigurationSection, isDouble, isEmpty, isFloat, isInt, isList, isLong, isSet, isShort, isString, remove, size
-
Constructor Details
-
YamlFile
public YamlFile()Builds thisYamlFilewithout any configuration file.In order to save changes you will have to use one of these methods before:
-setConfigurationFile(File)
-setConfigurationFile(String)
Or set the file when saving changes withFileConfiguration.save(File) -
YamlFile
Builds thisYamlFilewithout any configuration file.In order to save changes you will have to use one of these methods before:
-setConfigurationFile(File)
-setConfigurationFile(String)
Or set the file when saving changes withFileConfiguration.save(File)- Parameters:
yamlImplementation- the implementation to use. Default isSimpleYamlImplementation, but you can provide other likeSnakeYamlImplementationor a custom implementation.
-
YamlFile
Builds thisFileConfigurationwith the file specified by path.- Parameters:
path- location for the configuration file- Throws:
IllegalArgumentException- if path is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
YamlFile
Builds thisFileConfigurationwith a source file.- Parameters:
file- the configuration file- Throws:
IllegalArgumentException- if file is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
YamlFile
Builds thisFileConfigurationwith the file specified by uri.- Parameters:
uri- of the configuration file- Throws:
IllegalArgumentException- if file is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
YamlFile
Builds thisFileConfigurationwith the file specified by url.- Parameters:
url- of the configuration file- Throws:
URISyntaxException- if this URL is not formatted strictly according to RFC2396 and cannot be converted to a URI.IllegalArgumentException- if file is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
-
Method Details
-
save
Saves thisFileConfigurationto the configuration file 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.
Comments copied will be those loaded with
loadWithComments()and those added withsetComment(String, String)orsetComment(String, String, CommentType).This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Throws:
IOException- if it hasn't been possible to save configuration fileIllegalArgumentException- if the configuration file is not set
-
saveToString
Saves thisYamlFileto a string and returns it.Comments copied will be those loaded with
loadWithComments()and those added withsetComment(String, String)orsetComment(String, String, CommentType).- Specified by:
saveToStringin interfaceLoadableConfiguration- Overrides:
saveToStringin classYamlConfiguration- Returns:
- String containing this configuration with comments.
- Throws:
IOException- if it hasn't been possible to save configuration file
-
setComment
Set a comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules ofYamlConfiguration.options()YamlConfigurationOptions.commentFormatter().- Specified by:
setCommentin interfaceCommentable- Parameters:
path- path of desired section or keycomment- the comment to add, # prefix is not neededtype- either above (BLOCK) or SIDE
-
setComment
Set a block comment above the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules ofYamlConfiguration.options()YamlConfigurationOptions.commentFormatter().- Specified by:
setCommentin interfaceCommentable- Parameters:
path- path of desired section or keycomment- the block comment to add, # character is not needed
-
setComment
public void setComment(String path, String comment, CommentType type, YamlCommentFormatter yamlCommentFormatter) Set a comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules of the providedYamlCommentFormatter.- Parameters:
path- path of desired section or keycomment- the comment to add, # prefix is not neededtype- either above (BLOCK) or SIDEyamlCommentFormatter- the comment formatter to use
-
setComment
public void setComment(String path, String comment, CommentType type, YamlCommentFormat yamlCommentFormat) Set a comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules of the providedYamlCommentFormat.- Parameters:
path- path of desired section or keycomment- the comment to add, # prefix is not neededtype- either above (BLOCK) or SIDEyamlCommentFormat- the comment format to use
-
setComment
Set a block comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules of the providedYamlCommentFormatter.- Parameters:
path- path of desired section or keycomment- the block comment to add, # prefix is not neededyamlCommentFormatter- the comment formatter to use
-
setComment
Set a block comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character. Comment format will follow the rules of the providedYamlCommentFormat.- Parameters:
path- path of desired section or keycomment- the block comment to add, # prefix is not neededyamlCommentFormat- the comment format to use
-
setBlankLine
Set a blank line at the beginning of the block comment. If currently there is no block comment for the provided path then it sets "\n" as the block comment.- Parameters:
path- path of desired section or key
-
getComment
Retrieve the comment of the section or value selected by path. Comment format will follow the rules ofYamlConfiguration.options()YamlConfigurationOptions.commentFormatter().- Specified by:
getCommentin interfaceCommentable- Parameters:
path- path of desired section or keytype- either above (BLOCK) or SIDE- Returns:
- the comment of the section or value selected by path, or null if that path does not have any comment of this type
-
getComment
Retrieve the block comment of the section or value selected by path. Comment format will follow the rules ofYamlConfiguration.options()YamlConfigurationOptions.commentFormatter().- Specified by:
getCommentin interfaceCommentable- Parameters:
path- path of desired section or key- Returns:
- the block comment of the section or value selected by path, or null if that path does not have any comment of type block
-
getComment
Retrieve the comment of the section or value selected by path. Comment format will follow the rules of the providedYamlCommentFormatter.- Parameters:
path- path of desired section or keytype- either above (BLOCK) or SIDEyamlCommentFormatter- the comment formatter to use- Returns:
- the comment of the section or value selected by path, or null if that path does not have any comment of this type
-
getComment
Retrieve the comment of the section or value selected by path. Comment format will follow the rules of the providedYamlCommentFormat.- Parameters:
path- path of desired section or keytype- either above (BLOCK) or SIDEyamlCommentFormat- the comment format to use- Returns:
- the comment of the section or value selected by path, or null if that path does not have any comment of this type
-
getComment
Retrieve the block comment of the section or value selected by path. Comment format will follow the rules of the providedYamlCommentFormatter.- Parameters:
path- path of desired section or keyyamlCommentFormatter- the comment formatter to use- Returns:
- the block comment of the section or value selected by path, or null if that path does not have any comment of type block
-
getComment
Retrieve the block comment of the section or value selected by path. Comment format will follow the rules of the providedYamlCommentFormat.- Parameters:
path- path of desired section or keyyamlCommentFormat- the comment format to use- Returns:
- the block comment of the section or value selected by path, or null if that path does not have any comment of type block
-
setCommentFormat
Change the comment formatter to one of the defaults provided byYamlCommentFormat. This will change the behaviour for parsing comments withgetComment(String, CommentType)and for dumping comments withsetComment(String, String, CommentType). If default behaviour does not suits you then change the format before calling one of these methods.- Parameters:
yamlCommentFormat- desired format to set/dump and get/parse comments
-
setCommentFormat
Change the comment formatter for parsing and dumping comments. This is a shortcut toYamlConfiguration.options()YamlConfigurationOptions.commentFormatter(YamlCommentFormatter). This will change the behaviour for parsing comments withgetComment(String, CommentType)and for dumping comments withsetComment(String, String, CommentType).- Parameters:
yamlCommentFormatter- desired formatter to set/dump and get/parse comments
-
getHeader
Gets the header of this configuration file. The string format will respect the rules of theYamlConfiguration.options()YamlConfigurationOptions.headerFormatter(). By default theYamlHeaderFormatteris used and the result string will not have a blank line at the end. Null is a valid value which will indicate that no header is applied. The default value is null.- Returns:
- header
-
setHeader
Sets the header that will be applied to the top of the saved output. This is a shortcut toYamlConfiguration.options()YamlConfigurationOptions.header(String). This header will be commented out and applied directly at the top of the generated output of this configuration file. The rules ofYamlConfiguration.options()YamlConfigurationOptions.headerFormatter()will be respected. By default theYamlHeaderFormatteris used and the header will have a blank line written at the end of the header in the file. It is not required to include a newline at the end of the header as it will automatically be applied, but you may include one if you wish for extra spacing. Null is a valid value which will indicate that no header is to be applied.- Parameters:
header- New header
-
path
Get a wrapper builder to set a value to the given path and optionally set comments. This is an alternative API for the following pattern:
You can achieve the same with:yamlFile.set("test.hello", "Hello"); yamlFile.setComment("test.hello", "Block comment"); yamlFile.setComment("test.hello", "Side comment", CommentType.SIDE);yamlFile.path("test.hello") .set("Hello") .comment("Block comment") .commentSide("Side comment");- Parameters:
path- path of the object or configuration to set- Returns:
- the wrapper builder
-
getCommentMapper
Get the comment mapper. This has access to read the comment nodes directly.- Returns:
- the comment mapper or null if this configuration is loaded without comments
- See Also:
-
set
Description copied from class:YamlConfigurationSets the specified path to the given value.If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.
Some implementations may have limitations on what you may store. See their individual javadocs for details. No implementations should allow you to store
Configurations orConfigurationSections, please useMemorySection.createSection(String)for that.- Specified by:
setin interfaceConfigurationSection- Overrides:
setin classYamlConfiguration- Parameters:
path- Path of the object to set.value- New value to set the path to.
-
setListNode
-
load
Loads configurations from this configuration file.This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.Note that this method will not load comments of original configuration file, if needed use
loadWithComments()instead.- Throws:
IOException- if it hasn't been possible to load fileInvalidConfigurationException- if there has been an error while parsing configuration fileFileNotFoundException- if configuration file is not found- See Also:
-
loadWithComments
Loads configurations from this configuration file including comments.This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.Use
load()instead to improve performance when configuration file has no comments or don't need it.- Throws:
IOException- if it hasn't been possible to load fileInvalidConfigurationException- if there has been an error while parsing configuration fileFileNotFoundException- if configuration file is not found- See Also:
-
load
public void load(SupplierIO.Reader readerSupplier) throws IOException, InvalidConfigurationException Loads thisYamlFilefrom 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.
If the file cannot be loaded for any reason, an exception will be thrown.
- Overrides:
loadin classYamlConfiguration- Parameters:
readerSupplier- a function providing the reader to load from (new instance)- Throws:
IOException- Thrown when underlying reader throws an IOException.InvalidConfigurationException- Thrown when the reader does not represent a valid Configuration.IllegalArgumentException- Thrown when reader is null.
-
createOrLoad
If this configuration file does not exist then it is created along with missing parent directories.Otherwise loads configurations from this configuration file.
This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Throws:
IOException- if it hasn't been possible to load fileInvalidConfigurationException- if there has been an error while parsing configuration fileFileNotFoundException- if configuration file is not found- See Also:
-
createOrLoadWithComments
If this configuration file does not exist then it is created along with missing parent directories.Otherwise loads configurations from this configuration file, including comments.
This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Throws:
IOException- if it hasn't been possible to load fileInvalidConfigurationException- if there has been an error while parsing configuration fileFileNotFoundException- if configuration file is not found- See Also:
-
exists
public boolean exists()Tests whether this configuration file exists.- Returns:
trueif and only if this configuration file exists;falseotherwise
-
createNewFile
Creates a new empty file atomically for this configuration file.Parent directories will be created if they do not exist.
- Parameters:
overwrite- indicates if file must be overwritten if it already exists. Note that if overwrite is set to false and there is already a file with that path file will not be created and no exception is thrown.- Throws:
IOException- if I/O error occurs creating the configuration file
-
createNewFile
Creates a new empty file atomically for this configuration file if and only if it does not already exist.Parent directories will be created if they do not exist.
- Throws:
IOException- if I/O error occurs creating the configuration file
-
deleteFile
Deletes this configuration file from disk.- Throws:
IOException- if file cannot be deleted
-
getSize
public long getSize()Returns the size of this configuration file.- Returns:
- the size, in bytes, of this configuration file.
-
getFilePath
Returns the absolute pathname string of this configuration file.- Returns:
- the absolute path where configuration file is located.
-
getConfigurationFile
Returns this configuration file where data is located.- Returns:
- the configuration file where this
FileConfigurationwrites.
-
setConfigurationFile
Rebuilds thisFileConfigurationwith the file specified by path.- Parameters:
path- location for the configuration file- Throws:
IllegalArgumentException- if path is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
setConfigurationFile
Rebuilds thisFileConfigurationwith the file specified by uri.- Parameters:
uri- of the configuration file- Throws:
IllegalArgumentException- if file is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
setConfigurationFile
Rebuilds thisFileConfigurationwith a source file.- Parameters:
file- the configuration file- Throws:
IllegalArgumentException- if file is null or is a directory.
Note that ifIllegalArgumentExceptionis thrown then this configuration file will be null.
-
copyTo
Copy this configuration file to another path, without deleting configuration file. If there is already a file on the other path it will be overwritten.- Parameters:
path- the location of the new file, including name (mustn't be a directory)- Returns:
- the new copied file
- Throws:
FileNotFoundException- if configuration file is not found as source to copyIllegalArgumentException- if path is a directory or it is nullIOException- if there I/O error occurs copying file
-
copyTo
Copy this configuration file to another file, without deleting configuration file.- Parameters:
file- destination file (mustn't be a directory)- Throws:
FileNotFoundException- if configuration file is not found as source to copyIllegalArgumentException- if path is a directory or it is nullIOException- if there I/O error occurs copying file
-
fileToString
Returns a representation of the already saved configuration file.- Returns:
- the configuration file disk contents, or null if the file does not exist
- Throws:
IOException- if configuration file cannot be read
-
toString
Returns a representation of this configuration file.- Overrides:
toStringin classMemorySection- Returns:
- a representation of this configuration file
If something goes wrong then this string is an error message.
-
loadConfiguration
Creates a newYamlFile, loading from the given file.This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Parameters:
file- Input filewithComments- if comments should be parsed- Returns:
- Resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if file is null
-
loadConfiguration
Creates a newYamlFile, loading from the given file (without comments).This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Parameters:
file- Input file- Returns:
- Resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if file is null- See Also:
-
loadConfigurationFromString
public static YamlFile loadConfigurationFromString(String contents, boolean withComments) throws IOException Creates a newYamlFile, loading from the specified string contents.If the file cannot be loaded for any reason, an exception will be thrown.
- Parameters:
contents- the contents to load fromwithComments- if comments should be parsed- Returns:
- resulting configuration
- Throws:
IOException- if underlying reader throws an IOException.InvalidConfigurationException- if the contents does not represent a valid Configuration.IllegalArgumentException- if contents is null.
-
loadConfigurationFromString
Creates a newYamlFile, loading from the specified string contents (without comments).If the file cannot be loaded for any reason, an exception will be thrown.
- Parameters:
contents- the contents to load from- Returns:
- resulting configuration
- Throws:
IOException- if underlying reader throws an IOException.InvalidConfigurationException- if the contents does not represent a valid Configuration.IllegalArgumentException- if contents is null.
-
loadConfiguration
public static YamlFile loadConfiguration(SupplierIO.Reader readerSupplier, boolean withComments) throws IOException Creates a newYamlFile, loading from the given reader.- Parameters:
readerSupplier- reader supplierwithComments- if comments should be parsed- Returns:
- resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if stream is null
-
loadConfiguration
Creates a newYamlFile, loading from the given reader (without comments).- Parameters:
readerSupplier- reader supplier- Returns:
- resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if stream is null
-
loadConfiguration
public static YamlFile loadConfiguration(SupplierIO.InputStream streamSupplier, boolean withComments) throws IOException Creates a newYamlFile, loading from the given stream.This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Parameters:
streamSupplier- input stream supplierwithComments- if comments should be parsed- Returns:
- Resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if stream is null
-
loadConfiguration
Creates a newYamlFile, loading from the given stream (without comments).This method will use the
YamlConfiguration.options()charsetencoding, which defaults to UTF8.- Parameters:
streamSupplier- input stream supplier- Returns:
- Resulting configuration
- Throws:
IOException- if configuration cannot be loadedIllegalArgumentException- if stream is null
-
loadConfiguration
@Deprecated public static YamlFile loadConfiguration(InputStream stream, boolean withComments) throws IOException Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.InputStream, boolean)- Throws:
IOException
-
loadConfiguration
Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.InputStream)- Throws:
IOException
-
loadConfiguration
@Deprecated public static YamlFile loadConfiguration(Reader reader, boolean withComments) throws IOException Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.Reader, boolean)- Throws:
IOException
-
loadConfiguration
Deprecated.this method loads the entire file into memory, for larger files please useloadConfiguration(SupplierIO.Reader)- Throws:
IOException
-
loadConfiguration(SupplierIO.InputStream)