using classloader to load files

This commit is contained in:
Brian Matzon 2003-06-17 21:21:11 +00:00
parent dc25f2fb17
commit 1cdc9f9b15
1 changed files with 4 additions and 16 deletions

View File

@ -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 {
url = new URL("file:///" + cwd + "/" + filename);
} catch (MalformedURLException mue) {
mue.printStackTrace();
}
System.out.println("Attempting to load: " + url);
try { try {
BufferedInputStream bis = new BufferedInputStream(url.openStream()); BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bufferLength = 4096; int bufferLength = 4096;