pom中
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.0.0</version>
</dependency>
build.gradle
implementation 'com.googlecode.libphonenumber:libphonenumber:8.0.0'
public static void main(String[] args) {
String[] countries = Locale.getISOCountries();
for (int i = 0; i < countries.length; i++)
{
String code=countries[i];
Locale locale = new Locale("zh", code);
String mDisplayName=locale.getDisplayName();
mDisplayName=mDisplayName.substring(mDisplayName.indexOf("("),mDisplayName.indexOf(")"));
System.out.println("+"+ PhoneNumberUtil.getInstance().getCountryCodeForRegion(code) +" "+mDisplayName);
}
}