Created
January 26, 2023 14:52
-
-
Save potat-dev/307fb5935a0859c531d1afc929a805d8 to your computer and use it in GitHub Desktop.
Get an ArrayList of all available character sets and their aliases in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.ArrayList; | |
import java.nio.charset.Charset; | |
public class GetCharsets { | |
public static ArrayList<String> getCharsets() { | |
String[] charsets = Charset.availableCharsets().keySet().toArray(new String[0]); | |
ArrayList<String> allCharsets = new ArrayList<String>(Arrays.asList(charsets)); | |
for (String charset : charsets) { | |
allCharsets.addAll(Charset.availableCharsets().get(charset).aliases()); | |
} | |
return allCharsets; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment