JAVA/Java 일반
java 2글자국가코드_및_국가명_리스트조회 프로그램
달사자!
2021. 8. 5. 15:25
간단한 Testcase로 확인용 작성
@Test
void 두글자국가코드_및_국가명_리스트조회() {
String[] countries = Locale.getISOCountries();
//Arrays.stream(countries).forEach(System.out::println); //2글자 국가코드 리스트 확인
for (String country : countries) {
Locale l = new Locale("en", country);
System.out.println(String.format("2글자 국가코드(ISO 3166-1 alpha-2): %s | 영문 국가명: %s | 한글 국가명: %s ", country, l.getDisplayCountry(new Locale("en")),
l.getDisplayCountry(new Locale("ko"))));
}
System.out.println("countries 갯수: " + countries.length);
Assertions.assertNotNull(countries);
Assertions.assertTrue(countries.length >= 200); //2021년기준 249개국이 존재.(200개 국가 이상을 assert 체크 기준으로 함)
}