package gui;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class AssetManager {

	public static byte[] getResource(String name) {
		// we first search it in files
		File f = new File(name);
		if (f.exists()){
			FileInputStream fis;
			try {
				fis = new FileInputStream(f);
				return fis.readAllBytes();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		// then in the jar
		InputStream is = ClassLoader.getSystemResourceAsStream(name);
		try {
			return is.readAllBytes();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

}
