- 浏览: 456525 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
yuan_bin1990:
您好,请问下demo如何运行啊,准备研究研究,但不知道入口啊。 ...
ssh2(struts2+spring2.5+hibernate3.3)自动生成代码程序 -
luyulong:
[b][/b][i][/i][ ...
jQuery进度条插件 jQuery progressBar -
txin0814:
mark..
读取文件目录 -
vurses:
[align=center][color=red][size= ...
include 与 jsp:include区别 -
Roshan2:
http://lijiejava.iteye.com/blog ...
Spring AOP 入门实例
package cn.feigme.util; import java.net.URL; import java.util.*; /** * Util class that will read properties from the WEB-INF/classes/directory * or by specifying a URL on the filesystem. * Also has a helper method for creating a platform independent URL. */ public class PropertyReader { /** * Retrieve the properties specified by the fileName * The property file should be in the WEB-INF/classess directory * Suppose you need to get the properties in the * web-inf/classes/config/application.properties , * you need to pass the propertyFile: config/application.properties * * @param propertyFile relative path to a properties file in the WEB-INF/classes directory * @return a <code>Properties<code> object based on the input file **/ public static Properties getProperties(String propertyFile) { try { URL url = getPropertiesURL(propertyFile); return getProperties(url); } catch (Exception e) { System.out.println("Error ocurred during properties retrieval"); System.out.println(e.getMessage()); return null; } } /** * This method will return a platform independent URL to a file * in the web-inf/classes direcotry. * * @param fileName relative path to a properties file in the WEB-INF/classes directory * @return a platform independent URL to the xml file. */ public static URL getPropertiesURL(String fileName) { try { System.out.println("Getting the properties URL"); URL url = null; url = PropertyReader.class.getResource("/" + fileName); String s = url.toString(); System.out.println("Filename of the properties file is: " + s); if (s.indexOf("file://") != -1) { int indexOf = s.indexOf("file://") + 6; String temp = s.substring(0, indexOf); System.out.println("temp = " + temp + " moet zijn file:/"); url = new URL(temp + "//" + s.substring(indexOf)); System.out.println("The url is now: " + url); } return url; } catch (Exception e) { System.out.println("Error ocurred during properties retrieval"); System.out.println(e.getMessage()); return null; } } /** * Retrieve the properties accesible through the specified URL * * @param url a reference to a properties file * @return a properties file **/ public static Properties getProperties(URL url) { try { Properties props = new Properties(); // Check for Solaris compatibility. // A // in the file protocol won't be found in Solaris. props.load(url.openStream()); System.out.println("Properties have been loaded: " + props); return props; } catch (Exception e) { System.out.println("Error ocurred during properties retrieval"); System.out.println(e.getMessage()); return null; } } }
发表评论
-
javascript 打印指定区域
2010-11-18 16:34 1553javascript网页html 打印指定区域在一张网页里面, ... -
MyEclipse 8.5 开发环境配置,汉化,Aptana2.0插件,SVN 插件,Flex Builder 3/4 插件安装
2010-10-26 14:27 1518MyEclipse 8.5 开发环境配置,汉化,Aptana2 ... -
java读取properties文件
2010-10-11 13:43 738使用J2SE API读取Properties文件的六种方法 1 ... -
dbcp基本配置和重连配置
2010-09-28 09:29 2625最近在看一些dbcp的相 ... -
JAVA实现文件转移
2010-09-28 09:26 911/** * //1.从旧文件拷贝内容到新文件 ... -
JAVA读写ftp
2010-09-21 16:41 3504import java.io.DataInputStream; ... -
apache tomcat mysql负载均衡和集群
2010-09-14 10:30 1661前言:公司开发了一个网站,估计最高在线人数是3万,并发人数最多 ... -
Flash Builder 4 正式版序列号
2010-09-01 15:51 3912江湖上又出现新的FlashBuilder(Flex4)序列号: ... -
利用 org.apache.commons.io.FileUtils快速读写文件
2010-08-17 10:33 2693利用 org.apache.commons.io.FileUt ... -
netbeans常用快捷键
2010-08-10 16:26 8851、Application应用程序的 ... -
ERWIN7.1注册码
2010-06-23 12:15 1331终于找到ERWIN7.1注册码,也可在ERWIN7.2上注册。 ... -
Java压缩文件zip
2010-06-21 09:42 1099可以使用jdk提供的java.util.zip包的类来进行文件 ... -
文件资源操作
2010-06-16 21:52 10541.访问文件资源 假设有一个文件地位于 ... -
Java Regex To Use
2010-06-16 21:46 778Java代码 /** * 得到 ... -
Java Random and Java Disabuse
2010-06-16 21:46 1092一、Random 1、创建Random ... -
java 线程池
2010-06-16 21:44 11231)threadpool.xml Java代码 ... -
使用ThreadLocal,隔离多个线程之间的共享冲突
2010-06-16 21:29 1506早在Java 1.2推出之时,Java平台中就引入了一个新的 ... -
MyEclipse下开发Web Service
2010-06-16 21:28 1493开发环境 Sun Java 5+ ... -
jexcel使用
2010-06-16 21:23 1412Java代码 package excel.jx ... -
用dom4j读写xml
2010-06-16 21:20 867一、例子 Java代码 public c ...
相关推荐
利用Java的Properties 类读取配置文件信息! 读取Properties文件的例子
读取properties文件工具类。使用时直接将工具类放到Java项目中,调用读取properties文件的方法即可。
读取properties文件返回map
js读取properties文件,很好用的。js读取properties文件,很好用的。js读取properties文件,很好用的。js读取properties文件,很好用的。
主要介绍了Python实现读取Properties配置文件的方法,结合实例形式分析了Python读取Properties配置文件类的定义与使用相关操作技巧,需要的朋友可以参考下
使用Java中的Properties类的方法,以及类加载器来读取配置文件中的信息。可以读取.properties文件和.cfg文件。详细代码+注释+测试例子
java实现properties文件读取
在我们平时写程序的时候,有些参数是经常改变的,而这种改变不是我们预知的。比如说我们开发了一个操作数据库的模块,在开发的时候我们...JDK 内置的java.util.Properties 类为我们操作.properties 文件提供了便利。
Properties读取映射资源文件,做了很好的安全检查,可是直接使用哈 ,用了才知道好不好
java 读取properties文件代码
NULL 博文链接:https://mov-webhobo.iteye.com/blog/1786416
ConfigFile configfile = ConfigFile.getInstance("ipConfig123.properties"); String ip = configfile.getkeyvalue("ip"); 可以取出ipConfig123.properties 文件中IP的内容
这里面有详细的处理maven项目中resources目录下的资源文件,方便快捷的得到或设置资源文件中的内容,本人亲测,里面还有示例
java类读取properties文件,简单易用,方便快捷。
java中properties文件读取demo
读取properties文件路径的两种方式.zip 文档说明+项目示例
读取Properties信息工具类,其中main方法中可以直接进行测试
spring读取properties.
JAVA读取properties的值,JAVA读取properties文件,JAVA读取properties的内容
如何装载properties文件并读取文件内容。