Class FileLocator

java.lang.Object
com.sun.tools.corba.ee.idl.som.cff.FileLocator

public abstract class FileLocator extends 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 Details

    • pp

      static final Properties pp
    • classPath

      static final String classPath
    • pathSeparator

      static final String pathSeparator
  • 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
       
      Returns:
      a NamedDataInputStream of the file
      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.
       
      Returns:
      a NamedDataInputStream of the file
      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.
      Returns:
      a NamedDataInputStream of the file
      Throws:
      FileNotFoundException - The requested class file could not be found.
      IOException - The requested class file could not be opened.
    • getFileNameFromStream

      public 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.
      Parameters:
      ds - stream to get file name from
      Returns:
      fully qualified file nae
    • isZipFileAssociatedWithStream

      public 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.
      Parameters:
      ds - stream to check
      Returns:
      if a zip file is associated with the stream
    • locateInZipFile

      private static NamedDataInputStream locateInZipFile(String zipFileName, String fileName, boolean wantClass, boolean buffered) throws ZipException, IOException
      Throws:
      ZipException
      IOException