您的位置:首页 > 运维架构

操作Properties文件

2015-09-10 11:24 363 查看
src下的data.properties

name=LinDL

pwd=12345

<pre name="code" class="java">package test.lindl.mor;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesTest {

public static void main(String[] args) throws IOException {
Properties properties=new Properties();
//		InputStream inputStream=PropertiesTest.class.getClassLoader().getResourceAsStream("data.properties");
InputStream inputStream=new FileInputStream("d:/data.properties");
properties.load(inputStream);
System.out.println("name:  "+properties.getProperty("name"));
System.out.println("pwd:  "+properties.getProperty("pwd"));
}
}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: