zoukankan      html  css  js  c++  java
  • Java method Exception throw with return instance.

    知识共享许可协议
    Work by Jianfei is licensed under a Creative Commons wei 3.0 Unported License.

    1. We will get an error if write the getInstance method like below, cause the StaticEnvLib() throw a exception but there is no try- catch to catch it during the return new method.

     
      
       
    public static StaticEnvLib getInstance()
         {
             
    return new StaticEnvLib(); 
         }

    public StaticEnvLib() throws IOException {     
         
            String filename 
    = "H:\\Darwin.ini";
            BufferedReader reader 
    = new BufferedReader(new InputStreamReader(     
                    
    new FileInputStream(filename), "UTF-8"));     
            read(reader);     
            reader.close();     
        }   

    2. Modify the StaticEnvLib to like below.

    public StaticEnvLib()  {     
         
            String filename 
    = "H:\\Darwin.ini";
            BufferedReader reader 
    = new BufferedReader(new InputStreamReader(     
                    
    new FileInputStream(filename), "UTF-8"));     
            read(reader);     
            reader.close();     
        } 

    知识共享许可协议
    Work by Jianfei is licensed under a Creative Commons wei 3.0 Unported License.
  • 相关阅读:
    ConcurrentHashMap 实现缓存类
    maven 时区设置&ip&jdk编译版本
    【Hutool】工具类之日期时间工具-DateUtil
    正则表达式
    kafka connector
    kafka
    debezium、kafka connector 解析 mysql binlog 到 kafak
    网络流
    斜率优化
    8.8
  • 原文地址:https://www.cnblogs.com/zencorn/p/2007498.html
Copyright © 2011-2022 走看看