今天 学习用到的一些知识(properties 读取,js 删除元素)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了今天 学习用到的一些知识(properties 读取,js 删除元素),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1871字,纯文字阅读大概需要3分钟。
内容图文
![今天 学习用到的一些知识(properties 读取,js 删除元素)](/upload/InfoBanner/zyjiaocheng/1174/9bda988f621f437498a3991f060bbff1.jpg)
1.properties文件位置的关系:当properties文件放在src目录下时,编译会自动把src里的文件放到bin文件平级,因此可用this.getClass.getClassLoader.getResourceAsStream(fileName)读取,当把properties文件放到包里时,则应加相应的包路径,如:
props.load(Test.class.getClassLoader().getResourceAsStream("abc.properties"));
package wang.hhtp; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; public class PropertiesUtils { private static PropertiesUtils propertiesUtils=null; privatestatic Map<String,String> proMap=new HashMap<String,String>(); private PropertiesUtils() { InputStream inputStream=null; try { Properties pro=new Properties(); inputStream =getClass().getClassLoader().getResourceAsStream("abc.properties"); pro.load(inputStream); Iterator ite=pro.keySet().iterator(); while(ite.hasNext()){ String key=(String) ite.next(); String value=pro.getProperty(key); proMap.put(key, value); } } catch (IOException e) { e.printStackTrace(); }finally{ try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } publicstatic PropertiesUtils getInstance(){ if(propertiesUtils ==null){ propertiesUtils=new PropertiesUtils(); } return propertiesUtils; } public String getValue(String key){ PropertiesUtils pro= PropertiesUtils.getInstance(); if(StringUtils.isNotBlank(key)){ String value=pro.proMap.get(key); return value; } return key; } }
2.也可以用 static 类静态加载
class Properties{ private static Properties props = new Properties(); static { try { props.load(Test.class.getClassLoader().getResourceAsStream("com/abc.properties")); } catch (Exception e) { e.printStackTrace(); } } publicstatic String getProperty(String key){ return props.getProperty(key); } }
3.js 删除 数组某个元素
参考:http://my.oschina.net/u/2331760/blog/511439
原文:http://www.cnblogs.com/heibaishizhe/p/5393797.html
内容总结
以上是互联网集市为您收集整理的今天 学习用到的一些知识(properties 读取,js 删除元素)全部内容,希望文章能够帮你解决今天 学习用到的一些知识(properties 读取,js 删除元素)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。