Class FileLocator
- java.lang.Object
-
- com.sun.tools.corba.ee.idl.som.cff.FileLocator
-
public abstract class FileLocator extends java.lang.Object
FileLocator is an abstract class (one that cannot be instantiated) that provides class methods for finding files in the directories or zip archives that make up the CLASSPATH.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
classPath
(package private) static java.lang.String
pathSeparator
(package private) static java.util.Properties
pp
-
Constructor Summary
Constructors Constructor Description FileLocator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getFileNameFromStream(java.io.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(java.io.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 java.io.DataInputStream
locateClassFile(java.lang.String classFileName)
locateClassFile returns a DataInputStream with mark/reset capability that can be used to read the requested class file.static java.io.DataInputStream
locateFileInClassPath(java.lang.String fileName)
locateFileInClassPath returns a DataInputStream that can be used to read the requested file.private static NamedDataInputStream
locateInZipFile(java.lang.String zipFileName, java.lang.String fileName, boolean wantClass, boolean buffered)
static java.io.DataInputStream
locateLocaleSpecificFileInClassPath(java.lang.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).
-
-
-
Method Detail
-
locateClassFile
public static java.io.DataInputStream locateClassFile(java.lang.String classFileName) throws java.io.FileNotFoundException, java.io.IOException
locateClassFile returns a DataInputStream with mark/reset capability that can be used to read the requested class file. The CLASSPATH is used to locate the class.- Parameters:
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
- Returns:
- a
NamedDataInputStream
of the file - Throws:
java.io.FileNotFoundException
- The requested class file could not be found.java.io.IOException
- The requested class file could not be opened.
-
locateLocaleSpecificFileInClassPath
public static java.io.DataInputStream locateLocaleSpecificFileInClassPath(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
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). The CLASSPATH is used to locate the file.- Parameters:
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.
- Returns:
- a
NamedDataInputStream
of the file - Throws:
java.io.FileNotFoundException
- The requested class file could not be found.java.io.IOException
- The requested class file could not be opened.
-
locateFileInClassPath
public static java.io.DataInputStream locateFileInClassPath(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
locateFileInClassPath returns a DataInputStream that can be used to read the requested file. The CLASSPATH is used to locate the file.- Parameters:
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.- Returns:
- a
NamedDataInputStream
of the file - Throws:
java.io.FileNotFoundException
- The requested class file could not be found.java.io.IOException
- The requested class file could not be opened.
-
getFileNameFromStream
public static java.lang.String getFileNameFromStream(java.io.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.- Parameters:
ds
- stream to get file name from- Returns:
- fully qualified file nae
-
isZipFileAssociatedWithStream
public static boolean isZipFileAssociatedWithStream(java.io.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.- Parameters:
ds
- stream to check- Returns:
- if a zip file is associated with the stream
-
locateInZipFile
private static NamedDataInputStream locateInZipFile(java.lang.String zipFileName, java.lang.String fileName, boolean wantClass, boolean buffered) throws java.util.zip.ZipException, java.io.IOException
- Throws:
java.util.zip.ZipException
java.io.IOException
-
-