資源簡介
代碼片段和文件信息
package?serialException;
import?java.io.IOException;
import?java.io.PrintWriter;
import?java.io.StringWriter;
/**
?*?負責將傳入的Exception中的錯誤信息提取出來并轉換成字符串;
?*?@author?zhong
?*
?*/
public?class?ExceptionWriter?{
/**
?*?將Exception中的錯誤信息封裝到字符串中并返回該字符串
?*?@param?e?包含錯誤的Exception
?*?@return?錯誤信息字符串
?*/
public?static?String?getErrorInfoFromException(Exception?e)?{?
????
???? StringWriter?sw?=?null;
???? PrintWriter?pw?=?null;
????
????????try?{??
????????????sw?=?new?StringWriter();??
????????????pw?=?new?PrintWriter(sw);??
????????????e.printStackTrace(pw);??
????????????return?“\r\n“?+?sw.toString()?+?“\r\n“;??
????????????
????????}?catch?(Exception?e2)?{??
????????????return?“出錯啦!未獲取到錯誤信息,請檢查后重試!“;??
????????}?finally?{
???????? try?{
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1132??2016-05-22?16:08??src\serialException\ExceptionWriter.java
?????文件????????288??2016-05-22?21:49??src\serialException\NoSuchPort.java
?????文件????????291??2016-05-22?21:49??src\serialException\NotASerialPort.java
?????文件????????266??2016-05-22?21:48??src\serialException\PortInUse.java
?????文件????????296??2016-05-22?21:48??src\serialException\ReadDataFromSerialPortFailure.java
?????文件????????290??2016-05-22?21:48??src\serialException\SendDataToSerialPortFailure.java
?????文件????????326??2016-05-22?21:48??src\serialException\SerialPortInputStreamCloseFailure.java
?????文件????????325??2016-05-22?21:48??src\serialException\SerialPortOutputStreamCloseFailure.java
?????文件????????306??2016-05-22?21:48??src\serialException\SerialPortParameterFailure.java
?????文件????????282??2016-05-22?21:48??src\serialException\TooManyListeners.java
?????文件???????4263??2016-05-24?11:18??src\serialPort\Client.java
?????文件???????4074??2016-05-22?18:55??src\serialPort\computer.png
?????文件??????13173??2016-05-24?11:52??src\serialPort\DataView.java
?????文件???????6603??2016-05-23?20:06??src\serialPort\SerialTool.java
?????目錄??????????0??2016-05-22?17:11??src\serialException
?????目錄??????????0??2016-05-24?10:50??src\serialPort
?????目錄??????????0??2016-05-24?10:50??src
-----------?---------??----------?-----??----
????????????????31915????????????????????17
評論
共有 條評論