public class

ClassFile

extends Object
java.lang.Object
   ↳ sun.tools.java.ClassFile

Class Overview

This class is used to represent a file loaded from the class path, and can either be a regular file or a zip file entry. WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.

Summary

Public Constructors
ClassFile(File file)
Constructor for instance representing a regular file
ClassFile(ZipFile zf, ZipEntry ze)
Constructor for instance representing a zip file entry
Public Methods
boolean exists()
Returns true if file exists.
String getAbsoluteName()
Get absolute name of file entry
InputStream getInputStream()
Returns input stream to either regular file or zip file entry
String getName()
Get name of file entry excluding directory name
String getPath()
Get file path.
boolean isDirectory()
Returns true if this is a directory.
boolean isZipped()
Returns true if this is zip file entry
long lastModified()
Return last modification time
long length()
Get length of file
String toString()
Returns a string representation of the object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ClassFile (File file)

Constructor for instance representing a regular file

public ClassFile (ZipFile zf, ZipEntry ze)

Constructor for instance representing a zip file entry

Public Methods

public boolean exists ()

Returns true if file exists.

public String getAbsoluteName ()

Get absolute name of file entry

public InputStream getInputStream ()

Returns input stream to either regular file or zip file entry

Throws
IOException

public String getName ()

Get name of file entry excluding directory name

public String getPath ()

Get file path. The path for a zip file entry will also include the zip file name.

public boolean isDirectory ()

Returns true if this is a directory.

public boolean isZipped ()

Returns true if this is zip file entry

public long lastModified ()

Return last modification time

public long length ()

Get length of file

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a string representation of the object.