return null when asset cannot be read
This commit is contained in:
parent
6f2f74089b
commit
d05c4ad0d1
@ -6,15 +6,20 @@ import org.oscim.backend.AssetAdapter;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||||
|
|
||||||
public class GdxAssetAdapter extends AssetAdapter{
|
public class GdxAssetAdapter extends AssetAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream openFileAsStream(String fileName) {
|
public InputStream openFileAsStream(String fileName) {
|
||||||
FileHandle file = Gdx.files.internal(fileName);
|
FileHandle file = Gdx.files.internal(fileName);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
throw new IllegalArgumentException("missing file " + fileName);
|
throw new IllegalArgumentException("missing file " + fileName);
|
||||||
|
|
||||||
return file.read();
|
try {
|
||||||
}
|
return file.read();
|
||||||
|
} catch (GdxRuntimeException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user