✎
编程开发网
首页
C语言
C++
面试
Linux
函数
Windows
数据库
下载
搜索
当前位置:
首页
->
AI编程基础
->
JAVA
Java Exception 捕获和展示(二)
2014-11-24 03:16:53
·
作者:
·
浏览:
4
标签:
Java
Exception
捕获
展示
试 */ public void test(){ try { String content = readFile(); System.out.println(content); String regEx = "Caused by:(.*)"; Pattern pat = Pattern.compile(regEx); Matcher mat = pat.matcher(content); boolean rs = mat.find(); System.out.println("found " + rs); System.out.println(mat.group(1)); // for(int i=1;i<=mat.groupCount();i++){ // System.out.println("found:" + mat.group(i)); // } } catch (Exception e) { e.printStackTrace(); } } public void test2(){ try { FileInputStream fis = new FileInputStream("d:\\test.txt"); fis.read(); } catch (Exception e) { e.printStackTrace(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); e.printStackTrace(new PrintStream(baos)); String exception = baos.toString(); System.out.println("exception:" + exception); } } public static void main(String[] args) { RegexpTest rt = new RegexpTest(); //rt.test(); rt.test2(); }
首页
上一页
1
2
下一页
尾页
2
/2/2