public static MediaLocator appArgToMediaLocator(String arg) {
URL url = null;
// Check if arg is a valid url
try {
return new MediaLocator(
new URL(arg) );
} catch( MalformedURLException e ) {}
// Check if it is a file name
try {
return new MediaLocator(
fileToURL(arg) );
}
catch( MalformedURLException e ) {}
catch( IOException e ) {}
// Default MediaLocator
return new MediaLocator(arg);
}