JDK 1.5 속성 load 메서드는 InputStream 만 가져오고 JDK 1.6+ load 메서드도 Reader를 가져옵니다. 유니 코드 문자가있는 문자열이 load (reader)가있는 JDK 1.6+의 등록 정보 객체에로드 될 때 아무런 문제가 없습니다. 그러나 JDK 1.5에는 load (InputStream) 메서드 만 있습니다. 속성에로드 될 때 유니 코드 문자가 올바르게로드되지 않습니다.JDK 1.5 속성 유니 코드 문자로로드
Properties props = new Properties();
ByteArrayInputStream bis = null;
Reader reader = null;
try {
bis = new ByteArrayInputStream(someStringWithUnicodeChars.getBytes("UTF-8"));
reader = new InputStreamReader(bis, "UTF-8");
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
props.load(reader); // This reads unicode characters correctly on JDK 1.6+
// There is no props.load(reader) method on JDK 1.5, so below method is used
props.load(bis);
// but Unicode characters are not loaded correctly.
다음 예제 문자열을 유니 코드 문자로 특성 개체에로드 할 수 있습니까? JDK의 도구를 존재에 그에
InputStream in = new ByteArrayInputStream(someStringWithUnicodeChars.getBytes("ISO-8859-1"));
Properties props = new Properties();
props.load(in);
일반적으로 당신은 특성 파일에서 유니 코드 이스케이프를 사용할 필요가 것입니다. – Kayaman