4
votes

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

1

1 Answers

2
votes

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");