static {
LinkedList<Locale> supported = new LinkedList<>();
File locales = new File("locale");
- for (File f : locales.listFiles()) {
- if ( !f.getName().endsWith(".xml")) {
- continue;
+ File[] listFiles = locales.listFiles();
+ if (listFiles != null) {
+ for (File f : listFiles) {
+ if ( !f.getName().endsWith(".xml")) {
+ continue;
+ }
+ String language = f.getName().split("\\.", 2)[0];
+ supported.add(getLocaleFromString(language));
}
- String language = f.getName().split("\\.", 2)[0];
- supported.add(getLocaleFromString(language));
}
Collections.sort(supported, new Comparator<Locale>() {
if ( !file.exists()) {
return null;
}
- Language lang = langs.get(locale.toString());
- if (lang == null) {
- synchronized (Language.class) {
- lang = langs.get(locale.toString());
- if (lang != null) {
- return lang;
- }
- try {
- lang = new Language(locale);
- langs.put(locale.toString(), lang);
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- }
+ synchronized (Language.class) {
+ Language lang = langs.get(locale.toString());
+ if (lang != null) {
+ return lang;
+ }
+ try {
+ lang = new Language(locale);
+ langs.put(locale.toString(), lang);
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
}
+ return lang;
}
- return lang;
}
public Locale getLocale() {