Question: Good day,

I want a function to check if there are any files inside a folder, if there is no folder, make the folder and then run itself (function) again.

```js
const fs = require('fs');
const writeFileAtomic = require('write-file-atomic');

class DataHandler {
    constructor() {
    }
}

DataHandler.prototype.checkDB = function() {
    return new Promise((resolve, reject) => {
        fs.readdir('./database', function (err, files) {
            if (err) {
                if (err.code = 'ENOENT') {
                    fs.mkdir('./database', () => {
                        return this.checkDB;
                    })
                } else {
                    reject();
                }
            }
            if (files) {
                console.log(files)
            }
        })
    })
}

module.exports = DataHandler;

```

I get errors using this, saying this.checkDB is not a function

Answer: 
You can't write to files inside your JAR file, because they aren't actually files, they are ZIP entries.

The easiest way to store configuration for a Java application is to use [Preferences](https://docs.oracle.com/en/java/javase/18/docs/api/java.prefs/java/util/prefs/Preferences.html):

```
Preferences prefs = Preferences.userNodeForPackage(MyApp.class);

```

Now all you have to do is use any of the get methods to read, and put methods to write.
You could also check on application startup whether a directory such as `${user.home}/${application_name}/data` exists.

If not, create it by extracting a predefined zip into this location.
Then just run your application which would load/write all the data in this directory.

No need to read/write to the classpath. No need to include 3rd party APIs. And modifying this initial data set would just mean to distribute a new zip to be extracted from.