public abstract class FileLocator extends Object
Constructor and Description |
---|
FileLocator() |
Modifier and Type | Method and Description |
---|---|
static String |
getFileNameFromStream(DataInputStream ds)
Returns the fully qualified file name associated with the passed
DataInputStream if the DataInputStream was created using one
of the static locate methods supplied with this class, otherwise
returns a zero length string.
|
static boolean |
isZipFileAssociatedWithStream(DataInputStream ds)
Returns an indication of whether the passed DataInputStream is
associated with a member of a zip file if the DataInputStream was
created using one of the static locate methods supplied with this
class, otherwise returns false.
|
static DataInputStream |
locateClassFile(String classFileName)
locateClassFile returns a DataInputStream with mark/reset
capability that can be used to read the requested class file.
|
static DataInputStream |
locateFileInClassPath(String fileName)
locateFileInClassPath returns a DataInputStream that can be used
to read the requested file.
|
static DataInputStream |
locateLocaleSpecificFileInClassPath(String fileName)
locateLocaleSpecificFileInClassPath returns a DataInputStream that
can be used to read the requested file, but the name of the file is
determined using information from the current locale and the supplied
file name (which is treated as a "base" name, and is supplemented with
country and language related suffixes, obtained from the current
locale).
|
public static DataInputStream locateClassFile(String classFileName) throws FileNotFoundException, IOException
classFileName
- The name of the class to locate. The class name
should be given in fully-qualified form, for example:
java.lang.Object java.io.DataInputStream
FileNotFoundException
- The requested class file
could not be found.IOException
- The requested class file
could not be opened.public static DataInputStream locateLocaleSpecificFileInClassPath(String fileName) throws FileNotFoundException, IOException
fileName
- The name of the file to locate. The file name
may be qualified with a partial path name, using '/' as the separator
character or using separator characters appropriate for the host file
system, in which case each directory or zip file in the CLASSPATH will
be used as a base for finding the fully-qualified file.
Here is an example of how the supplied fileName is used as a base
for locating a locale-specific file:
Supplied fileName: a/b/c/x.y, current locale: US English Look first for: a/b/c/x_en_US.y (if that fails) Look next for: a/b/c/x_en.y (if that fails) Look last for: a/b/c/x.y All elements of the class path are searched for each name, before the next possible name is tried.
FileNotFoundException
- The requested class file
could not be found.IOException
- The requested class file
could not be opened.public static DataInputStream locateFileInClassPath(String fileName) throws FileNotFoundException, IOException
fileName
- The name of the file to locate. The file name
may be qualified with a partial path name, using '/' as the separator
character or using separator characters appropriate for the host file
system, in which case each directory or zip file in the CLASSPATH will
be used as a base for finding the fully-qualified file.FileNotFoundException
- The requested class file
could not be found.IOException
- The requested class file
could not be opened.public static String getFileNameFromStream(DataInputStream ds)
public static boolean isZipFileAssociatedWithStream(DataInputStream ds)
Copyright © 2019 JBoss by Red Hat. All rights reserved.