|
@@ -1,7 +1,7 @@
|
|
package cn.com.qmth.examcloud.commons.util;
|
|
package cn.com.qmth.examcloud.commons.util;
|
|
|
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.PrintWriter;
|
|
import java.io.PrintWriter;
|
|
|
|
+import java.io.StringWriter;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -56,18 +56,18 @@ public class Util {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static String getStackTrace(Exception e) {
|
|
public static String getStackTrace(Exception e) {
|
|
- ByteArrayOutputStream os = null;
|
|
|
|
- PrintWriter printWriter = null;
|
|
|
|
|
|
+ PrintWriter pw = null;
|
|
|
|
+ StringWriter sw = null;
|
|
try {
|
|
try {
|
|
- os = new ByteArrayOutputStream();
|
|
|
|
- printWriter = new PrintWriter(os);
|
|
|
|
- e.printStackTrace(printWriter);
|
|
|
|
- return printWriter.toString();
|
|
|
|
|
|
+ sw = new StringWriter();
|
|
|
|
+ pw = new PrintWriter(sw);
|
|
|
|
+ e.printStackTrace(pw);
|
|
|
|
+ return sw.toString();
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
throw new RuntimeException(ex);
|
|
throw new RuntimeException(ex);
|
|
} finally {
|
|
} finally {
|
|
- IOUtils.closeQuietly(printWriter);
|
|
|
|
- IOUtils.closeQuietly(os);
|
|
|
|
|
|
+ IOUtils.closeQuietly(pw);
|
|
|
|
+ IOUtils.closeQuietly(sw);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|