Tag: GetMessage () printstacktrace ()
Public class exceptiontest07{public static void main (String[] args) {try{ Fileinputstream fis = new fileinputstream ("C:/abc.txt");//JVM executed this code for US// Filenotfoundexception e = new filenotfoundexception ("c:\abc.txt " (the system cannot find the specified file.) )");} catch (Filenotfoundexception e) {//print exception stack information.//Generally use this method to debug the program.//e.printstacktrace ();/* java.io.filenotfoundexception: c:\abc.txt (the system cannot find the file specified.) ) at java.io.fileinputstream.open (Native Method) at java.io.FileInputStream.<init> ( fileinputstream.java:106) at java.io.FileInputStream.< Init> (fileinputstream.java:66) at exceptiontest07.main ( EXCEPTIONTEST07.JAVA:13) */ &nbSp; string msg = e.getmessage ();// E.getmassage from the JVM has executed this code for us, Filenotfoundexception e = new filenotfoundexception ("C: \ abc.txt (the system cannot find the file specified.) ) "); SYSTEM.OUT.PRINTLN (msg); //c:\abc.txt (the system cannot find the file specified.) }//this code will execute. System.out.println ("ABC");}}
This article is from the "Gaogaozi" blog, make sure to keep this source http://hangtiangazi.blog.51cto.com/8584103/1661698
GetMessage () and Printstacktrace methods in Java