1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 |
public class TestDriver { public
static void main(String[] args) throws
IOException { File file = new
File( "e:\\test.config" ); //模拟load()方法将指定流中的属性列表加载到properties中,指定文件必须是键值对形式 Properties ps = new
Properties(); BufferedReader bufR = new
BufferedReader( new
FileReader(file)); String bufStr = null ; while ((bufStr = bufR.readLine()) != null ){ if (bufStr.startsWith( "#" )){ continue ; } String[] strs = bufStr.split( "=" ); ps.setProperty(strs[ 0 ], strs[ 1 ]); } System.out.println( "=================" ); ps.list(System.out); } } |
这就相当于
1
2
3
4
5
6
7
8
9
10
11
12 |
public class TestDriver { public
static void main(String[] args) throws
IOException { File file = new
File( "e:\\test.config" ); //load()方法将指定流中的属性列表加载到properties中,指定文件必须是键值对形式 Properties ps = new
Properties(); System.out.println( "=================" ); ps.load( new
FileReader(file)); ps.list(System.out); } } |
模拟load()方法将指定流中的属性列表加载到properties中,布布扣,bubuko.com
模拟load()方法将指定流中的属性列表加载到properties中
原文:http://www.cnblogs.com/lxricecream/p/3590636.html