Carleslc / Simple-YAML

This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
https://carleslc.me/Simple-YAML
GNU General Public License v3.0
132 stars 38 forks source link

file.getName(); #32

Closed Java4Life17 closed 4 years ago

Java4Life17 commented 4 years ago

When ever I try to get a File name with file.getName(); it returns nothing.

portlek commented 4 years ago

it does not return the file name. it's for the current section's name.

Carleslc commented 4 years ago

Use yamlFile.getConfigurationFile().getName() to get the file name, or yamlFile.getFilePath() to get the absolute path.

getName is a method of ConfigurationSection ([docs](https://carleslc.me/Simple-YAML/doc/Simple-Configuration/org/simpleyaml/configuration/ConfigurationSection.html#getName())) that returns the name of the configuration section. YamlFile implements ConfigurationSection (is the file's root section), so yamlFile.getName() returns the same as yamlFile.getRoot().getName(), which is blank because root path is blank (yamlFile.getCurrentPath() is blank too, for the same reason).

For instance, yamlFile.getConfigurationSection("test").getName() will return test.