Libgdx How to get a list of files in a directory

The "internal files" are found via the classpath when run on the desktop, so there is no simple way to "list" a directory in the classpath. If you're just using the desktop for development, and don't mind some hacks you can search "./bin/" for the missing files.

Like this:

**/
FileHandle dirHandle;
if (Gdx.app.getType() == ApplicationType.Android) {
   dirHandle = Gdx.files.internal("some/directory");
} else {
  // ApplicationType.Desktop ..
  dirHandle = Gdx.files.internal("./bin/some/directory");
}
for (FileHandle entry: dirHandle.list()) {
   // yadda ...
}

 For a bit more detail, see: http://bitiotic.com/blog/2012/05/15/libgdx-internal-files-hacks/

 

你可能感兴趣的:(Directory)