Class FileLocator
java.lang.Object
com.sun.tools.corba.se.idl.som.cff.FileLocator
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.
- Author:
- Larry K. Raper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns 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 booleanReturns 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 DataInputStreamlocateClassFile(String classFileName) locateClassFile returns a DataInputStream with mark/reset capability that can be used to read the requested class file.static DataInputStreamlocateFileInClassPath(String fileName) locateFileInClassPath returns a DataInputStream that can be used to read the requested file.static DataInputStreamlocateLocaleSpecificFileInClassPath(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).
-
Constructor Details
-
FileLocator
public FileLocator()
-
-
Method Details
-
locateClassFile
public static DataInputStream locateClassFile(String classFileName) throws FileNotFoundException, 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- Throws:
FileNotFoundException- The requested class file could not be found.IOException- The requested class file could not be opened.
-
locateLocaleSpecificFileInClassPath
public static DataInputStream locateLocaleSpecificFileInClassPath(String fileName) throws FileNotFoundException, 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.- Throws:
FileNotFoundException- The requested class file could not be found.IOException- The requested class file could not be opened.
-
locateFileInClassPath
public static DataInputStream locateFileInClassPath(String fileName) throws FileNotFoundException, 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.- Throws:
FileNotFoundException- The requested class file could not be found.IOException- The requested class file could not be opened.
-
getFileNameFromStream
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. -
isZipFileAssociatedWithStream
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.
-