org.apache.bcel.util

## Class ClassPath

- java.lang.Object
- - org.apache.bcel.util.ClassPath

-     public class ClassPath
      extends Object

  Responsible for loading (class) files from the CLASSPATH. Inspired by sun.tools.ClassPath.
  Version:
    $Id: ClassPath.java 1806200 2017-08-25 16:33:06Z ggregory $

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ClassPath.ClassFile` Contains information about file/ZIP entry of the Java class.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ClassPath` | `SYSTEM_CLASS_PATH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassPath()` Deprecated. Use SYSTEM_CLASS_PATH constant
    `ClassPath(ClassPath parent, String class_path)`
    `ClassPath(String class_path)` Search for classes in given path.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `byte[]` | `getBytes(String name)`
    `byte[]` | `getBytes(String name, String suffix)`
    `ClassPath.ClassFile` | `getClassFile(String name)`
    `ClassPath.ClassFile` | `getClassFile(String name, String suffix)`
    `static String` | `getClassPath()` Checks for class path components in the following properties: "java.class.path", "sun.boot.class.path", "java.ext.dirs"
    `InputStream` | `getInputStream(String name)`
    `InputStream` | `getInputStream(String name, String suffix)` Return stream for class or resource on CLASSPATH.
    `String` | `getPath(String name)`
    `String` | `getPath(String name, String suffix)`
    `URL` | `getResource(String name)`
    `InputStream` | `getResourceAsStream(String name)`
    `Enumeration<URL>` | `getResources(String name)`
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### SYSTEM_CLASS_PATH

          public static final ClassPath SYSTEM_CLASS_PATH

  - ### Constructor Detail

    - #### ClassPath

          public ClassPath(ClassPath parent,
                           String class_path)

    - #### ClassPath

          public ClassPath(String class_path)

      Search for classes in given path.
      Parameters:
        `class_path` -

    - #### ClassPath

          @Deprecated
          public ClassPath()

      Deprecated. Use SYSTEM_CLASS_PATH constant
      Search for classes in CLASSPATH.

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`
      Returns:
        used class path string

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### getClassPath

          public static String getClassPath()

      Checks for class path components in the following properties: "java.class.path", "sun.boot.class.path", "java.ext.dirs"
      Returns:
        class path as used by default by BCEL

    - #### getInputStream

          public InputStream getInputStream(String name)
                                     throws IOException

      Parameters:
        `name` - fully qualified class name, e.g. java.lang.String
      Returns:
        input stream for class
      Throws:
        `IOException`

    - #### getInputStream

          public InputStream getInputStream(String name,
                                            String suffix)
                                     throws IOException

      Return stream for class or resource on CLASSPATH.
      Parameters:
        `name` - fully qualified file name, e.g. java/lang/String
        `suffix` - file name ends with suff, e.g. .java
      Returns:
        input stream for file on class path
      Throws:
        `IOException`

    - #### getResourceAsStream

          public InputStream getResourceAsStream(String name)

      Parameters:
        `name` - fully qualified resource name, e.g. java/lang/String.class
      Returns:
        InputStream supplying the resource, or null if no resource with that name.
      Since:
        6.0

    - #### getResource

          public URL getResource(String name)

      Parameters:
        `name` - fully qualified resource name, e.g. java/lang/String.class
      Returns:
        URL supplying the resource, or null if no resource with that name.
      Since:
        6.0

    - #### getResources

          public Enumeration<URL> getResources(String name)

      Parameters:
        `name` - fully qualified resource name, e.g. java/lang/String.class
      Returns:
        An Enumeration of URLs supplying the resource, or an empty Enumeration if no resource with that name.
      Since:
        6.0

    - #### getClassFile

          public ClassPath.ClassFile getClassFile(String name,
                                                  String suffix)
                                           throws IOException

      Parameters:
        `name` - fully qualified file name, e.g. java/lang/String
        `suffix` - file name ends with suff, e.g. .java
      Returns:
        class file for the java class
      Throws:
        `IOException`

    - #### getClassFile

          public ClassPath.ClassFile getClassFile(String name)
                                           throws IOException

      Parameters:
        `name` - fully qualified class name, e.g. java.lang.String
      Returns:
        input stream for class
      Throws:
        `IOException`

    - #### getBytes

          public byte[] getBytes(String name,
                                 String suffix)
                          throws IOException

      Parameters:
        `name` - fully qualified file name, e.g. java/lang/String
        `suffix` - file name ends with suffix, e.g. .java
      Returns:
        byte array for file on class path
      Throws:
        `IOException`

    - #### getBytes

          public byte[] getBytes(String name)
                          throws IOException

      Returns:
        byte array for class
      Throws:
        `IOException`

    - #### getPath

          public String getPath(String name)
                         throws IOException

      Parameters:
        `name` - name of file to search for, e.g. java/lang/String.java
      Returns:
        full (canonical) path for file
      Throws:
        `IOException`

    - #### getPath

          public String getPath(String name,
                                String suffix)
                         throws IOException

      Parameters:
        `name` - name of file to search for, e.g. java/lang/String
        `suffix` - file name suffix, e.g. .java
      Returns:
        full (canonical) path for file, if it exists
      Throws:
        `IOException`

Copyright © 2004–2017 The Apache Software Foundation. All rights reserved.