Unfortunately, the ResourceBundle API doesn't offer facilities for that. For every requested locale it just tries to locate it and if none is found, then the closest candiate/fallback locale will be tried repeatedly.
One of the ways to reveal them all would be to just scan the classpath for the files yourself.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
final String bundlepackage = "com.example.i18n";
final String bundlename = "messages";
File root = new File(loader.getResource(bundlepackage.replace('.', '/')).getFile());
File[] files = root.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.matches("^" + bundlename + "(_\\w{2}(_\\w{2})?)?\\.properties$");
}
});
Set<String> languages = new TreeSet<String>();
for (File file : files) {
languages.add(file.getName().replaceAll("^" + bundlename + "(_)?|\\.properties$", ""));
}