I have a very big problem with the file system of LibGDX
. I need a list of all files in a folder inside my jar-file. I tried different things, but the best working code is:
FileHandle dirHandle;
if (Gdx.app.getType() == ApplicationType.Android) {
dirHandle = Gdx.files.internal("levels");
} else {
// ApplicationType.Desktop ..
dirHandle = Gdx.files.internal("./bin/levels");
}
for (FileHandle entry: dirHandle.list()) {
Gdx.app.log("FILE", entry.name() + " " + entry.path());
//DO some other stuff...
}
The problem is, if I export it, this code do not work at all.
Normally I can get the internal file path, but the exported jar just crashes.
It throws a NullPointerException
, because there are no files in it.
I have checked the path, it is C:/Users/user/./bin/levels
.
Logical, but bad for me.
How can I get a list of internal files from a exported jar?
I just need the names of the files, e.g. mission1.xml
in my case or whatever.trash
!
I don't have an idea, maybe I made or make a big mistake, so please help me, if you can.