# File loader

File loader loads data into a list from YAML files.

File loader must extend AbstractFileLoader.

**How to create a loader from a single file?**

```java
public class MyFileLoader extends AbstractFileLoader<UserCoins> {
    
    @Override
    public void load() {
        load("users_coins.yml", "users");
    }
    
    @Override
    public void load(String fileName, String primarySection) {
      loadFile(fileName, primarySection, (key, section) -> 
          this.addObject(section.getObject(key, UserCoins.class)));
    }
}
```

**How to create a loader from a many files?**

```java
public class MyManyFilesLoader extends AbstractFileLoader<UserCoins> {
    
    @Override
    public void load() {
        File file = new File(MiniGame.getInstance().getDataFolder(), "users");

        File[] files = file.listFiles();

        if (files == null) return;

        for (File childFile : files) {
            load(childFile.getAbsolutePath(), "user");
        }
    }
    
    @Override
    public void load(String fileName, String primarySection) {
        File file = new File(fileName);

     loadFile(file , primarySection, (key, section) -> 
          this.addObject(section.getObject(key, UserCoins.class)));
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://timsixths-plugins.gitbook.io/minigameapi-docs/minigameapi-1.x/basic-features/loaders/loader/file-loader.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
