Loading Files

How to load files using zAPI

Loading/Creating YAML Files

In order to load YAML files using zAPI you will use a class used FileUtils, to manage and load your file, first things first, you need to define your file:

File file = new File(getDataFolder(), "file.yml");

Then after defining your file, you create a FileUtils, using that file:

FileUtils fileUtils = new FileUtils(file, "file.yml");

Then to load it you can use:

fileUtils.saveDefaultConfig(); // Load the file or create it if not exist, also prevents from options to be deleted from it
fileUtils.reloadConfig(false); // Saves the file if created now, keep in mind that if you change that false to true, any deleted options from it, will always come back, which in some cases are not required

Getting and Managing existing files

To get a existing file (Already loaded), you need to use FileManager class, that saves every loaded FileUtils and can restore it to you:

FileManager.getFileUtil("file.yml");

You can also use FileManager.getFiles() to get all FileUtils that were loaded

Last updated

Was this helpful?