zoukankan      html  css  js  c++  java
  • Java 把异常传递给控制台

    最简答而又不用写多少代码就能保护异常信息的方法,就是把它们从main()传递到控制台,对于简单的程序可以像这样:

    package exceptions;
    //: exceptions/MainException.java
    import java.io.*;
    
    public class MainException {
      // Pass all exceptions to the console:
      public static void main(String[] args) throws Exception {
        // Open the file:
        FileInputStream file =
          new FileInputStream("MainException.java");
        // Use the file ...
        // Close the file:
        file.close();
      }
    } ///:~

     通过把它传递到控制它这里就不必写try-catch子句了.

  • 相关阅读:
    19软件工程专业---调查问卷
    软件工程2020思维导图
    关于创新创业
    学习周记
    学习周记
    问卷
    思维导图
    关于创新
    哈弗曼树
    调查问卷
  • 原文地址:https://www.cnblogs.com/jiangfeilong/p/10303244.html
Copyright © 2011-2022 走看看