---
title: "Java Exception"
author: "newand"
date: "2008-06-06T13:52:30Z"
tags: []
slug: "java-exception"
draft: false
lastmod: "2008-06-06T13:52:30Z"
id: 200905
url: "https://newand.iteye.com/blog/200905"
---

**Throwable(是所有Error和Exception的超类)** 的一些API：

1.getCause（）

2.getStackTrace() 得到 StackTraceElement

 

StackTraceElement

    |-&gt;  getFileName        得到产生异常的文件名

    |-&gt;  getLineNumber    得到异常发生的代码行

    |-&gt;  getMethodName  得到发生异常的方法

 

可以使用这些API来改变异常输出的格式。