|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.moyoman.client.reference.util.FileSupport
Provides file system methods for reading icons, input streams, properties,
and directory listings. These methods search for files in the following order:
1. MOYOMAN_HOME directory
2. classpath (includes the application jar)
3. user.dir System property
Also provides methods to ensure the existence of directories, and to copy Jar contents into a local directory.
| Field Summary | |
private static String |
_baseDirectory
The base directory. |
private static String |
_jarFilename
The jar filename. |
private static String |
_moyomanDirectory
The Moyoman home directory. |
private static String |
_userDirectory
The user directory. |
| Constructor Summary | |
FileSupport()
|
|
| Method Summary | |
static void |
copyDirectoryContentFromJar(String relativePath0)
Copy the content of the given relative path in the Jar to the base directory plus relative path. |
static void |
ensureDirectoryExists(String relativePath)
Ensure the given directory exists. |
private static String |
formatJarPath(String path)
Format the given filepath to start with a forward slash. |
private static String |
formatPath(String path)
Format the given filepath to start with a file separator. |
static AudioClip |
getAudioClip(String relativeFilePath)
Return the audio clip from the given filename. |
private static AudioClip |
getAudioClipFromURL(URL url)
Return the audio clip from the given URL. |
static String |
getBaseDirectory()
Return the base application directory. |
static Icon |
getIcon(String relativeFilePath)
Return the icon from the given filename. |
private static Icon |
getIconFromClasspath(String relativeFilePath)
Return the icon from the classpath from the given file. |
private static Icon |
getIconFromDirectory(String directory,
String relativeFilePath)
Return the icon from the given directory and file. |
static InputStream |
getInputStream(String relativeFilePath)
Return an input stream for the given file. |
private static InputStream |
getInputStreamFromClasspath(String relativeFilePath)
Return the input stream from the classpath. |
private static InputStream |
getInputStreamFromDirectory(String directory,
String relativeFilePath)
Return an input stream for the given filename. |
static Properties |
getProperties(String relativeFilePath)
Return the properties from the given filename. |
static boolean |
isWindowsApplication()
Return true if this application is running on Windows. |
static String[] |
listFiles(String relativePath,
String filePrefix,
String fileSuffix)
List the files in the given directory which have the given file prefix and the given file suffix. |
private static String[] |
listFilesFromDirectory(String baseDirectory,
String relativePath,
String filePrefix,
String fileSuffix)
List the files in the given directory which have the given file prefix and the given file suffix. |
private static String[] |
listFilesFromJar(String jarFilename,
String relativePath,
String filePrefix,
String fileSuffix)
List the files from the Jar in the given directory which have the given file prefix and the given file suffix. |
static void |
main(String[] args)
Test method. |
private static boolean |
matchesPrefix(String name,
String prefix)
Return true if the given name matches the file prefix. |
private static boolean |
matchesSuffix(String name,
String suffix)
Return true if the given name matches the file suffix. |
static void |
setJarFilename(String jarFilename)
Set the jar filename. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final String _moyomanDirectory
private static final String _userDirectory
private static String _jarFilename
private static final String _baseDirectory
| Constructor Detail |
public FileSupport()
| Method Detail |
public static AudioClip getAudioClip(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.
public static String getBaseDirectory()
MOYOMAN_HOME System property, or if that's null, the
user.dir System property.
public static Icon getIcon(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.
public static InputStream getInputStream(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.public static void setJarFilename(String jarFilename)
jarFilename - The new jar filename.public static Properties getProperties(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.
public static boolean isWindowsApplication()
public static void copyDirectoryContentFromJar(String relativePath0)
relativePath0 - The path relative to the base directory.public static void ensureDirectoryExists(String relativePath)
relativePath - The relative directory path.
SecurityException - if the application has no rights to create the
directory.
public static String[] listFiles(String relativePath,
String filePrefix,
String fileSuffix)
relativePath - The relative directory path.filePrefix - The file prefix (ignored if null).fileSuffix - The file suffix (ignored if null).public static void main(String[] args)
private static AudioClip getAudioClipFromURL(URL url)
url - URL.private static Icon getIconFromClasspath(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.
private static Icon getIconFromDirectory(String directory,
String relativeFilePath)
directory - The directory.relativeFilePath - The file path relative to the base directory.private static InputStream getInputStreamFromClasspath(String relativeFilePath)
relativeFilePath - The file path relative to the base directory.
private static InputStream getInputStreamFromDirectory(String directory,
String relativeFilePath)
directory - The directory.relativeFilePath - The file path relative to the base directory.private static String formatJarPath(String path)
private static String formatPath(String path)
private static String[] listFilesFromDirectory(String baseDirectory,
String relativePath,
String filePrefix,
String fileSuffix)
baseDirectory - The base directory.relativePath - The relative directory path.filePrefix - The file prefix (ignored if null).fileSuffix - The file suffix (ignored if null).
private static String[] listFilesFromJar(String jarFilename,
String relativePath,
String filePrefix,
String fileSuffix)
jarFilename - The jar filename.relativePath - The relative directory path.filePrefix - The file prefix (ignored if null).fileSuffix - The file suffix (ignored if null).
private static boolean matchesPrefix(String name,
String prefix)
private static boolean matchesSuffix(String name,
String suffix)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||