# Class ClassPath

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

All Implemented Interfaces:
  `Closeable, AutoCloseable`

public class ClassPath extends Object implements Closeable
Loads class files from the CLASSPATH. Inspired by sun.tools.ClassPath.

- ## Nested Class Summary

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final ClassPath`
  `SYSTEM_CLASS_PATH`
  The system class path.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClassPath()`
  Deprecated.
  Use SYSTEM_CLASS_PATH constant
  `ClassPath(String classPath)`
  Search for classes in given path.
  `ClassPath(ClassPath parent, String classPathString)`
  Constructs a ClassPath with a parent and class path string.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `boolean`
  `equals(Object obj)`
  `byte[]`
  `getBytes(String name)`
  Gets byte array for the given class.
  `byte[]`
  `getBytes(String name, String suffix)`
  Gets byte array for the given file.
  `ClassPath.ClassFile`
  `getClassFile(String name)`
  Gets the input stream for the given class.
  `ClassPath.ClassFile`
  `getClassFile(String name, String suffix)`
  Gets the class file for the given Java class.
  `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)`
  Gets an InputStream.
  `InputStream`
  `getInputStream(String name, String suffix)`
  Gets an InputStream for a class or resource on the classpath.
  `String`
  `getPath(String name)`
  Gets the full canonical path for the given file.
  `String`
  `getPath(String name, String suffix)`
  Gets the full canonical path for the given file.
  `URL`
  `getResource(String name)`
  Gets the URL for the given resource.
  `InputStream`
  `getResourceAsStream(String name)`
  Gets the InputStream for the given resource.
  `Enumeration<URL>`
  `getResources(String name)`
  Gets an Enumeration of URLs for the given resource.
  `int`
  `hashCode()`
  `String`
  `toString()`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### SYSTEM_CLASS_PATH

    public static final ClassPath SYSTEM_CLASS_PATH
    The system class path.

- ## Constructor Details

  - ### ClassPath

    @Deprecated public ClassPath()
    Deprecated.
    Use SYSTEM_CLASS_PATH constant
    Search for classes in CLASSPATH.

  - ### ClassPath

    public ClassPath(ClassPath parent, String classPathString)
    Constructs a ClassPath with a parent and class path string.
    Parameters:
      `parent` - the parent ClassPath.
      `classPathString` - the class path string.

  - ### ClassPath

    public ClassPath(String classPath)
    Search for classes in given path.
    Parameters:
      `classPath` - the class path string.

- ## Method Details

  - ### 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.

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### getBytes

    public byte[] getBytes(String name) throws IOException
    Gets byte array for the given class.
    Parameters:
      `name` - fully qualified file name, for example java/lang/String.
    Returns:
      byte array for class.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getBytes

    public byte[] getBytes(String name, String suffix) throws IOException
    Gets byte array for the given file.
    Parameters:
      `name` - fully qualified file name, for example java/lang/String.
      `suffix` - file name ends with suffix, for example .java.
    Returns:
      byte array for file on class path.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getClassFile

    public ClassPath.ClassFile getClassFile(String name) throws IOException
    Gets the input stream for the given class.
    Parameters:
      `name` - fully qualified class name, for example `String`.
    Returns:
      input stream for class.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getClassFile

    public ClassPath.ClassFile getClassFile(String name, String suffix) throws IOException
    Gets the class file for the given Java class.
    Parameters:
      `name` - fully qualified file name, for example java/lang/String.
      `suffix` - file name ends with suffix, for example .java.
    Returns:
      class file for the Java class.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getInputStream

    public InputStream getInputStream(String name) throws IOException
    Gets an InputStream.

    The caller is responsible for closing the InputStream.

    Parameters:
      `name` - fully qualified class name, for example `String`.
    Returns:
      input stream for class.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getInputStream

    public InputStream getInputStream(String name, String suffix) throws IOException
    Gets an InputStream for a class or resource on the classpath.

    The caller is responsible for closing the InputStream.

    Parameters:
      `name` - fully qualified file name, for example java/lang/String.
      `suffix` - file name ends with suff, for example .java.
    Returns:
      input stream for file on class path.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getPath

    public String getPath(String name) throws IOException
    Gets the full canonical path for the given file.
    Parameters:
      `name` - name of file to search for, for example java/lang/String.java.
    Returns:
      full (canonical) path for file.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getPath

    public String getPath(String name, String suffix) throws IOException
    Gets the full canonical path for the given file.
    Parameters:
      `name` - name of file to search for, for example java/lang/String.
      `suffix` - file name suffix, for example .java.
    Returns:
      full (canonical) path for file, if it exists.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getResource

    public URL getResource(String name)
    Gets the URL for the given resource.
    Parameters:
      `name` - fully qualified resource name, for example java/lang/String.class.
    Returns:
      URL supplying the resource, or null if no resource with that name.
    Since:
      6.0

  - ### getResourceAsStream

    public InputStream getResourceAsStream(String name)
    Gets the InputStream for the given resource.
    Parameters:
      `name` - fully qualified resource name, for example java/lang/String.class.
    Returns:
      InputStream supplying the resource, or null if no resource with that name.
    Since:
      6.0

  - ### getResources

    public Enumeration<URL> getResources(String name)
    Gets an Enumeration of URLs for the given resource.
    Parameters:
      `name` - fully qualified resource name, for example 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

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`
    Returns:
      used class path string.