Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file.getName(); #32

Closed
Java4Life17 opened this issue Aug 19, 2020 · 2 comments
Closed

file.getName(); #32

Java4Life17 opened this issue Aug 19, 2020 · 2 comments

Comments

@Java4Life17
Copy link

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

@portlek
Copy link
Contributor

portlek commented Aug 19, 2020

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

@Carleslc
Copy link
Owner

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

getName is a method of ConfigurationSection (docs) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants