import java.io.*; import java.util.Properties; /** * UTF-8 エンコーディングされたプロパティファイルを {@link Properties} クラスで取り扱う。 */ public class PropertiesWithUtf8 { static Properties loadUtf8Properties(String resourceName) throws IOException { try (InputStream is = PropertiesWithUtf8.class.getResourceAsStream(resourceName); InputStreamReader isr = new InputStreamReader(is, "UTF-8"); BufferedReader reader = new BufferedReader(isr)) { Properties result = new Properties(); // Properties#load() で渡す Reader オブジェクトを UTF-8 エンコーディング指定して生成した // InputStreamReader オブジェクトにする result.load(reader); return result; } } public static void main(String[] args) throws IOException { Properties prop = loadUtf8Properties("/utf8.properties"); System.out.println(prop.getProperty("いろはにほへと")); } }