# Where to create JSON file written from module (linux)

**URL:** <https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976>\
**Category:** Module Development\
**Tags:** ignition81\
**Created:** [May 19, 2023, 9:38pm UTC](https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976 "2023-05-19T21:38:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarah\_Sonnier](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sarah_sonnier/32/80232_2.png) [@Sarah\_Sonnier](https://forum.inductiveautomation.com/u/Sarah_Sonnier)\
**Post date:** [May 19, 2023, 9:38pm UTC](https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976/1 "2023-05-19T21:38:41Z")

</div>

Hey everyone,

I have a module that writes a JSON file to a folder that the module creates in the data directory. When the file doesn't exist, my module creates the JSON file. On Windows this is \Ignition\data{myDirectory}. This works 100% of the time on Windows.  
I use context.getSystemManager().getDataDir().getPath() to get the location, and it is agnostic, meaning it works on Windows and Linux installs.

An issue I'm having in Linux environments is the data directory doesn't allow me to write to it. My module can read and write to the file in that location with no problem, but cannot create the file to begin with.

I'm wondering if there is a better place to put this file, other than the data directory, without these Linux permissions issues, or if there is another way around this hiccup.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 19, 2023, 9:55pm UTC](https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976/2 "2023-05-19T21:55:01Z")

</div>

How are you creating your folder?

{Consider not using `.getPath()` on any [File](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html) object--use that object's normal methods and constructors to manipulate paths in a platform-neutral way.}

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 19, 2023, 9:57pm UTC](https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976/3 "2023-05-19T21:57:46Z")

</div>

The recommended pattern for persistent, non-configuration data (i.e. something your module wants to reference or cache, but should not be included in a gateway backup) would be `$dataDir/modules/$yourModuleId/`. The gateway service should absolutely have access to create files or directories in that folder, so I would echo Phil's question about exactly how you're creating the file(s).

---

<div class="post-metadata">

**Author:** ![Sarah\_Sonnier](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sarah_sonnier/32/80232_2.png) [@Sarah\_Sonnier](https://forum.inductiveautomation.com/u/Sarah_Sonnier)\
**Post date:** [May 22, 2023, 7:13pm UTC](https://forum.inductiveautomation.com/t/where-to-create-json-file-written-from-module-linux/73976/4 "2023-05-22T19:13:21Z")

</div>

I looked and it looks like I am making the directory with the file if it doesn't exist like this

```auto
FileWriter file = new FileWriter(path);

```

where I should be creating a directory first and then the file like this

```auto
new File(path).mkdirs();

```

and then creating the file. I will give that a shot, thank you for the answer!
