package sound;

import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.imageio.ImageIO;

public abstract class ResourceLoader {
	private static Map<String,Object> loaded = new HashMap<String,Object>();
	
	
	public static Object load(String path) {
		return load(path, true);
	}
	public static Object load(String path, boolean cache) {
		if(cache && loaded.containsKey(path)){
			return loaded.get(path);
		}
		else{
			//CHANGED : CODEMONKEYSTILISH CODE
			/*	if(path.endsWith(".dat"))
					obj = cl.getResourceAsStream(path);
				else
					obj = ImageIO.read(is);
			*/
			ClassLoader cl = ResourceLoader.class.getClassLoader();
			BufferedInputStream bis = new BufferedInputStream(cl.getResourceAsStream(path));
			Object obj;
			try{
				if((obj = AudioIO.read(bis)) == null)
					if((obj = ImageIO.read(bis)) == null)
						if((obj = cl.getResourceAsStream(path)) == null)
							throw new FileNotFoundException("Couldn't read file: "+path); 
			}catch(IOException ioe){
				System.err.println(ioe.getMessage());
				obj = null;
			}
			if(cache) loaded.put(path, obj);
			return obj;
		}
	}
	
	/*public static InputStream getStream(String path) {
		return ResourceLoader.class.getClassLoader().getResourceAsStream(path);
	}*/
}

@@ -201,16 +201,52 @@
 eIO;%0D%0A%0D%0A
+/**%0D%0A * Handles the Resources%0D%0A */%0D%0A
 public a
@@ -438,309 +438,366 @@
 %7D%0D%0A%09
-public static Object load(String path, boolean cache) %7B%0D%0A%09%09if(cache && loaded.containsKey(path))%7B%0D%0A%09%09%09return loaded.get(path);%0D%0A%09%09%7D%0D%0A%09%09else%7B%0D%0A%09%09%09//CHANGED : CODEMONKEYSTILISH CODE%0D%0A%09%09%09/*%09if(path.endsWith(%22.dat%22))%0D%0A%09%09%09%09%09obj = cl.getResourceAsStream(path);%0D%0A%09%09%09%09else%0D%0A%09%09%09%09%09obj = ImageIO.read(is);%0D%0A%09%09%09*/
+/**%0D%0A%09 * Loads a file and stores its content. %0D%0A%09 * Returns its content if it was already loaded before%0D%0A%09 * %0D%0A%09 * @param path Path to the file%0D%0A%09 * @param cache Determines if the file should be cached or not %0D%0A%09 */%0D%0A%09public static Object load(String path, boolean cache) %7B%0D%0A%09%09if(cache && loaded.containsKey(path))%7B%0D%0A%09%09%09return loaded.get(path);%0D%0A%09%09%7D%0D%0A%09%09else%7B
 %0D%0A%09%09
@@ -1339,146 +1339,7 @@
 %09%7D%0D%0A
-%09%0D%0A%09/*public static InputStream getStream(String path) %7B%0D%0A%09%09return ResourceLoader.class.getClassLoader().getResourceAsStream(path);%0D%0A%09%7D*/%0D%0A
 %7D%0D%0A

Update ResourceLoader.java