com.b3dgs.lionengine.utility
Class Media

java.lang.Object
  extended by com.b3dgs.lionengine.utility.Media

public class Media
extends java.lang.Object

Allow to grab ressources with ease.


Method Summary
static java.lang.String get(java.lang.String... path)
          Get a media from its path (start by defaut in the ressources dir).
static java.io.File getFile(java.lang.String outfile, java.io.InputStream stream)
          Copy stream into a temporary file and return this file (localized on current system).
static java.lang.String getRessourcesDir()
          Get current ressources directory.
static java.io.InputStream getStream(java.lang.String path)
          Get stream of specified path.
static java.io.File getTempFile(java.lang.String filename, boolean cache)
          Get a temporary file, including cache check.
static void loadFromJar(java.lang.Class<?> cloader)
          Activate ressources loading from *.jar
static java.lang.String separator()
          Get current separator character (equals / in case of applet, else OS dependant).
static void setRessourcesDir(java.lang.String dir)
          Define ressources dir.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

separator

public static java.lang.String separator()
Get current separator character (equals / in case of applet, else OS dependant).

Returns:
separator.

loadFromJar

public static void loadFromJar(java.lang.Class<?> cloader)
Activate ressources loading from *.jar

Parameters:
cloader - class loader reference (ressources entry point).

setRessourcesDir

public static void setRessourcesDir(java.lang.String dir)
Define ressources dir. Root for all game medias.

Parameters:
dir - main root dir.

getRessourcesDir

public static java.lang.String getRessourcesDir()
Get current ressources directory.

Returns:
ressources directory.

get

public static java.lang.String get(java.lang.String... path)
Get a media from its path (start by defaut in the ressources dir). Example: Media.get("sprites", "hero.png") will return ressources/sprites/hero.png. This function is OS independant !

Parameters:
path - list of folders (if has) and file.
Returns:
full media path.
See Also:
setRessourcesDir(java.lang.String)

getStream

public static java.io.InputStream getStream(java.lang.String path)
Get stream of specified path.

Parameters:
path - input path, pointing to a file.
Returns:
opened input stream.

getFile

public static java.io.File getFile(java.lang.String outfile,
                                   java.io.InputStream stream)
Copy stream into a temporary file and return this file (localized on current system).

Parameters:
outfile - file which will store stream.
stream - input stream.
Returns:
file containing a copy of the input stream.

getTempFile

public static java.io.File getTempFile(java.lang.String filename,
                                       boolean cache)
Get a temporary file, including cache check.

Parameters:
filename - original filename (may be inside a jar).
cache - cache state (true will check if file is not already cached).
Returns:
copy of original file (may be cached file reference).