GetMessage () and Printstacktrace methods in Java

Source: Internet
Author: User
Tags getmessage

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.