import java.nio.charset.Charset;
import java.util.Locale;

/**
 * {@link <a href=
 * "https://[Log in to view URL]"
 * target="_blank">Gestori supportati dalla JVM: encoders, decoders,
 * geografico-politici</a>}
 * 
 * @author itammb ( Italia Massimiliano Buscati )
 * @version JDK 1.15
 *
 */
class Main {
	/**
	 * @see Charset#availableCharsets()
	 * @see Charset#aliases()
	 * @see Charset#defaultCharset()
	 * 
	 */
	public static void printAvailableCharsets() {
		Charset.availableCharsets().forEach((name, charsets) -> {
			System.out.println("[[" + name + "], [" + charsets.aliases() + "]]");
		});

		// l'encoder di default della JVM viene configurato nei parametri di run

		// javaw.exe -Dfile.encoding=UTF-8 -classpath
		// "C:\Galileo\Eclipse-Workspace\Galileo_v1_3\bin"
		// -XX:+ShowCodeDetailsInExceptionMessages
		// org.buscati.knowledge.example.Example_006_05_No_Primitive_String_CharsetAndLocate
		System.out.println(Charset.defaultCharset());
	}

	/**
	 * @see Locale#getAvailableLocales()
	 * @see Locale#getDefault()
	 * 
	 */
	public static void printAvailableLocales() {
		for (Locale locale : Locale.getAvailableLocales())
			System.out.println(printLocale(locale));

		System.out.println(Locale.getDefault());

		// imposta un gestore specifico per la JVM
		Locale.setDefault(Locale.ENGLISH);
	}

	/**
	 * @see Locale#toLanguageTag()
	 * @see Locale#getLanguage()
	 * @see Locale#getCountry()
	 * @see Locale#getScript()
	 * 
	 */
	private static String printLocale(Locale locale) {
		return "[[" + locale.toString() + "], [" + locale.toLanguageTag() + "], [" + locale.getDisplayName() + "],  ["
				+ locale.getLanguage() + "], [" + locale.getCountry() + "], [" + locale.getScript() + "]]";
	}

	public static void main(String args[]) throws Exception {
		// Unit test - stampa gli encoders supportati dalla JVM
		printAvailableCharsets();

		System.out.println();

		// Unit test - stampa i gestori geografico-politici supportati dalla JVM
		printAvailableLocales();
	}
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: