4

I have the following problem

InputStream input = FileHandle.class.getResourceAsStream("/data/sounds/back.ogg");

returns null, but

InputStream input = FileHandle.class.getResourceAsStream("/data/sounds/back.png");

returns InputStream, also both files are in this folder. What can be wrong?

I'm using libgdx-0.9.6

Daahrien
  • 10,190
  • 6
  • 39
  • 71
Kirill Bubochkin
  • 5,868
  • 2
  • 31
  • 50

1 Answers1

2

If your path starts with "/", java will search your file in the root of your file system.

If it is in your root folder, first of all, check if file exists:

ls -l /data/sounds/ | grep "back.ogg"

If it does not exists or you do not have permissions, then you have the answer.

If it exists, you could try another way to get its InputStream:

InputStream is = new FileInputStream("/data/sounds/back.ogg");
arutaku
  • 5,937
  • 1
  • 24
  • 38