LibGDX - Can't read file file from assets folder using FileReader

Hi all

I Seem to have a really weird issue happening which I’m a little stumped on. I’m trying to load in some JSON data into the Desktop project so I’m having to use the FileReader class as the Gdx class doesn’t exist in this context.

I can put the file inside of another folder and it loads without any issues… but as soon as I put it within the desktop assets folder, I get an IOException with file not found. Surely the FileReader should still be able to access this folder?

Why’s that? You should have access to all Gdx classes. Only issue I can think of is that Gdx.files might not be initialized if used before ApplicationListener.create().

Anyhow, “new FileHandle(“path/relative/to/your/working/dir/your.json”).file()” should work just fine. Just make sure you set the debugging configuration’s working directory to the assets folder.

Is there a reason you’re trying to read the JSON file from the desktop project? What’s the problem with just putting it in the core project?

I agree. Just put your resources on the core project. Easier to manage files when they all are in the same place (mostly).

Unless your doing a Android project when every asset has to be on android/assets and you have to link your desktop projects working directory to point to android/assets.