lxw
2023-11-22 cba96d4cbd3ddd8af20b2d65d1f430c75f667821
src/main/java/com/whyc/properties/LinkProperties.java
@@ -28,16 +28,25 @@
     * 从指定路径加载信息到Properties 
     * @param path 
     */  
    public LinkProperties(String path) {
    public LinkProperties(String path) {
        InputStream is=null;
        try {  
            InputStream is = new FileInputStream(path);
            is = new FileInputStream(path);
            this.load(is);  
        } catch (FileNotFoundException e) {  
            e.printStackTrace();  
            throw new RuntimeException("指定文件不存在!");  
        } catch (IOException e) {  
            e.printStackTrace();  
        }
        } finally {
            if(is!=null){
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }  
      
    /** 
@@ -88,21 +97,29 @@
     * @param path 指定路径 
     * @param charset 文件编码 
     */  
    public void store(String path, String charset) {
    public void store(String path, String charset) {
        OutputStream os =null;
        if (path != null && !"".equals(path)) {  
            try {  
                OutputStream os = new FileOutputStream(path);
                os = new FileOutputStream(path);
                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, charset));  
                this.store(bw, null);  
                bw.close();
            } catch (FileNotFoundException e) {
            } catch (FileNotFoundException e) {
                e.printStackTrace();  
            } catch (IOException e) {  
                e.printStackTrace();  
            }
            } finally {
                if(os!=null){
                    try {
                        os.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        } else {  
            throw new RuntimeException("存储路径不能为空!");  
        }
        }
    }  
  
    /**