Example #1
0
 /** 获取File对象输入流,即使在Jar文件中一样工作良好!! <b>强烈推荐</b> */
 protected static InputStream _input(File file) throws IOException {
   if (file.exists()) return new FileInputStream(file);
   if (Scans.isInJar(file)) {
     NutResource nutResource = Scans.makeJarNutResource(file);
     if (nutResource != null) return nutResource.getInputStream();
   }
   throw new FileNotFoundException(file.toString());
 }
Example #2
0
 /**
  * 加载指定文件/文件夹的Properties文件,合并成一个Properties对象
  *
  * <p><b style=color:red>如果有重复的key,请务必注意加载的顺序!!<b/>
  *
  * @param paths 需要加载的Properties文件路径
  */
 public void setPaths(String... paths) {
   mp = new MultiLineProperties();
   List<NutResource> list = Scans.me().loadResource("^.+[.]properties$", paths);
   try {
     if (utf8) for (NutResource nr : list) mp.load(nr.getReader());
     else {
       Properties p = new Properties();
       for (NutResource nr : list) {
         p.load(nr.getInputStream());
       }
       mp.putAll(p);
     }
   } catch (IOException e) {
     throw Lang.wrapThrow(e);
   }
 }