public <T> T getFile (String filename, Class<T> resourceType) {
        URL file;
        try {
            file = getFileName(filename);
        }
        catch (FileNotFoundException e1) {
            return null;
        }

        try {
            if (queueFile(file)) {
                load();
                try {
                    // Wait for loading to complete
                    myLoadThread.join();
                }
                catch (InterruptedException e) {
                    System.out.println("Error waiting for threads.");
                }
            }
        }
        catch (FileNotSupportedException e) {
            return null;
        }

        Object loadedFile = myResourceStorage.get(file);
        if (resourceType.isAssignableFrom(loadedFile.getClass())) {
            return resourceType.cast(loadedFile);
        }
        return null;
    }