ITeye博客

【Java】读取properties文件的两种方式

JavaPerl · 2010-12-07 20:39 · 【Java】 · 编程语言 · Markdown


package com.test.property;

import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;

public class TestProperty {
	
	public static void main(String[] args) throws Exception
	{
		System.out.println(ResourceBundle.getBundle("test",Locale.CHINA).getString("hello"));
		
		InputStream is = TestProperty.class.getResourceAsStream("/test_zh_CN.properties");
		
		Properties prop =new Properties();
		
		prop.load(is);
		
		System.out.println(prop.getProperty("hello"));
	}
	
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。