KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > StackTraceElement

java.lang
Class StackTraceElement

java.lang.Object
  extended by java.lang.StackTraceElement
All Implemented Interfaces:
Serializable
See Also:
Top Examples, Source Code, Throwable.getStackTrace()

public boolean equals(Object obj)
See Also:
Hashtable, Object.hashCode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getClassName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getFileName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getLineNumber()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getMethodName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isNativeMethod()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StackTraceElement(String declaringClass,
                         String methodName,
                         String fileName,
                         int lineNumber)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Throwable.printStackTrace(), Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1359]Displaying stack trace in any part of the codes
By Anonymous on 2005/03/23 15:57:48  Rate
/*  
  * Displaying stack trace in any part of the codes 
  * 
  * Using the new Java v1.4 facilities in the Throwable class  
  * to pull in formation out of a stack trace. 
  */
 
   
  
  
 ... //Some where in my code 
  
  
 displayStackTraceInformation ( new Throwable (  )  ) ; 
 ... 
  
  
  
 public static boolean displayStackTraceInformation ( Throwable ex )   {  
  
  
   if  ( null == ex )   {  
     System.out.println ( "Null stack trace reference! Bailing..." ) ; 
     return false; 
    }  
  
  
   StringBuffer sbMsg = new StringBuffer (  ) ; 
  
  
   StackTraceElement [  ]  stackElements = ex.getStackTrace (  ) ; 
  
  
   sbMsg.append ( "The " + stackElements.length + " element" 
       +  (  ( stackElements.length == 1 )  ? "" : "s" )  
       + " of the stack trace:\n" ) ; 
  
  
   for  ( int lcv = 0; lcv  <  stackElements.length; lcv++ )   {  
     sbMsg.append ( "\n" + stackElements [ lcv ] .toString (  )  ) ; 
  
  
    }  
  
  
   System.out.println ( sbMsg.toString (  )  ) ; 
   return true; 
  }   
 

Popular Tags