java对iostream的操作很方便的,你自己看看书不就知道了,我也正在看呢
解决方案 »
- jar打包出错的问题
- 我编写了个Swing 程序现要打成jar包运行,但我程序中使用了很多第三方的包如dom4j.jar等。请问怎么打包
- SWT 关于SWT StyledText内存占用问题
- 用java实现ftp的多线程下载
- 有没有办法判断一个String当前的编码格式???
- 一个大厅n个房间,每个房间里的逻辑模型相同,但是有定时事件,如何实现这种模型?
- java怎么看版本号?
- 谁有JBuilder4的Licensing,帮忙告诉我一下,我买的盗版碟不正版。
- 各位高手,本人如此之菜,难道不屑一顾
- 求助: Java POI如何输出带函数公式的单元格
- 用java如何生成曲线图,像网站上动态股票图一样。并且一定和后台数据库相连!!!
- 哪位大虾有together5.5的key?
Class Properties
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--java.util.PropertiesDirect Known Subclasses:
Provider --------------------------------------------------------------------------------public class Properties
extends Hashtable
The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string. A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list. Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail.
FileInputStream in=null;
Properties props=new Properties(); System.out.println(System.getProperty("user.dir")); String fileName="info.properties";
try{
in=new FileInputStream(fileName);
}catch(FileNotFoundException fnf)
{
fnf.printStackTrace();
return;
}
try{
props.load(in);
}catch(IOException ioex)
{
ioex.printStackTrace();
return;
} String driver=props.getProperty("jdbc.driver","oracle.jdbc.driver.OracleDriver");
String url=props.getProperty("jdbc.url","jdbc:oracle:thin:@localhost:1521");
String user=props.getProperty("jdbc.user","system");
String password=props.getProperty("jdbc.password","manager");
属性文件(info.properties)如下:
jdbc.driver oracle.jdbc.driver.OracleDriver
jdbc.url jdbc:oracle:thin:@localhost:1521
jdbc.user system
jdbc.password manager
只要将String fileName="info.properties";
改成String fileName="info.ini";即可