| | |
| | | * 从指定路径加载信息到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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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("存储路径不能为空!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |