---
title: "【Java】读取properties文件的两种方式"
author: "JavaPerl"
date: "2010-12-07T20:39:25Z"
tags: []
categories: ["编程语言"]
slug: "java-properties"
draft: false
lastmod: "2010-12-07T20:44:06Z"
id: 836089
url: "https://javaperl.iteye.com/blog/836089"
---

```java

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"));
	}
	
}

```