using classloader to load files
This commit is contained in:
parent
dc25f2fb17
commit
1cdc9f9b15
|
@ -36,8 +36,6 @@ import org.lwjgl.openal.AL;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
@ -65,8 +63,8 @@ public class PlayTestMemory extends BasicTest {
|
||||||
*/
|
*/
|
||||||
protected void execute(String[] args) {
|
protected void execute(String[] args) {
|
||||||
if(args.length < 1) {
|
if(args.length < 1) {
|
||||||
System.out.println("please specify filename to play");
|
System.out.println("no argument supplied, assuming Footsteps.wav");
|
||||||
return;
|
args = new String[] {"Footsteps.wav"};
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastError;
|
int lastError;
|
||||||
|
@ -161,20 +159,10 @@ public class PlayTestMemory extends BasicTest {
|
||||||
protected ByteBuffer getData(String filename) {
|
protected ByteBuffer getData(String filename) {
|
||||||
ByteBuffer buffer = null;
|
ByteBuffer buffer = null;
|
||||||
|
|
||||||
URL url = null;
|
System.out.println("Attempting to load: " + filename);
|
||||||
|
|
||||||
String cwd = System.getProperty("user.dir");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
url = new URL("file:///" + cwd + "/" + filename);
|
BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
|
||||||
} catch (MalformedURLException mue) {
|
|
||||||
mue.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Attempting to load: " + url);
|
|
||||||
|
|
||||||
try {
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(url.openStream());
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
int bufferLength = 4096;
|
int bufferLength = 4096;
|
||||||
|
|
Loading…
Reference in New Issue