コード例 #1
0
ファイル: Main.java プロジェクト: Cat7373/HMCL
 public static ImageIcon getIcon(String path) {
   try {
     return new ImageIcon(
         Main.class.getResource("/org/jackhuang/hellominecraft/launcher/" + path));
   } catch (Exception e) {
     HMCLog.err("Failed to load icon", e);
     return null;
   }
 }
コード例 #2
0
ファイル: Localization.java プロジェクト: TekkitCommando/HMCL
  private Localization(Locale locale) {
    InputStream is =
        Localization.class.getResourceAsStream(
            String.format(ROOT_LOCATION, "_" + locale.getLanguage() + "_" + locale.getCountry()));
    if (is == null)
      is =
          Localization.class.getResourceAsStream(
              String.format(ROOT_LOCATION, "_" + locale.getLanguage()));
    if (is == null) is = Localization.class.getResourceAsStream(String.format(ROOT_LOCATION, ""));
    if (is == null) throw new RuntimeException("LANG FILE MISSING");

    this.lang = new HashMap<>();
    try {
      String[] strings = IOUtils.readFully(is).toString().split("\n");
      for (String s : strings)
        if (!s.isEmpty() && s.charAt(0) != 35) {
          int i = s.indexOf("=");
          if (i == -1) continue;
          lang.put(s.substring(0, i), s.substring(i + 1));
        }
    } catch (IOException ex) {
      HMCLog.err("LANG FILE MISSING", ex);
    }
  }