
ResourceBundle::getLocales() 메소드는 파라미터를 받지 않고 Locale을 반환합니다. 이 메소드는 ResourceBundle의 Locale 목록을 반환하므로, ResourceBundle 객체를 생성할 때 사용됩니다.
ResourceBundle 객체를 생성할 때, Locale을 지정하지 않으면 기본 Locale이 사용됩니다. 이때, ResourceBundle::getLocales() 메소드를 사용하여 Locale 목록을 얻을 수 있습니다.
예를 들어, 다음 코드는 ResourceBundle::getLocales() 메소드를 사용하여 Locale 목록을 얻는 방법을 보여줍니다.
#hostingforum.kr
java
ResourceBundle bundle = ResourceBundle.getBundle("messages");
Locale[] locales = bundle.getLocales();
for (Locale locale : locales) {
System.out.println(locale.toString());
}
이 코드는 "messages" 이름의 ResourceBundle 객체를 생성하고, Locale 목록을 얻어 출력합니다.
ResourceBundle::getLocales() 메소드는 ResourceBundle 객체를 생성할 때 사용되는 대표적인 방법 중 하나입니다. 이 메소드는 Locale 목록을 반환하므로, Locale을 지정할 때 유용하게 사용할 수 있습니다.
2025-03-31 12:37