示例#1
0
  private boolean extractFile(LightPoles plugin, String name) {
    InputStream is = plugin.getClass().getClassLoader().getResourceAsStream(name);
    try {
      File configFile = new File(plugin.getDataFolder(), name);
      if (!configFile.getParentFile().exists()) {
        configFile.getParentFile().mkdirs();
      }

      extractFile(is, configFile);
    } catch (IOException e) {
      LightPoles.log("# could not extract file: " + name, new Object[0]);
      return false;
    }
    LightPoles.log("# extracted file: " + name, new Object[0]);
    return true;
  }
示例#2
0
  private boolean extractFileFromFolder(LightPoles plugin, String name, String path) {
    InputStream is =
        plugin.getClass().getClassLoader().getResourceAsStream(path + File.separator + name);
    try {
      File folder = new File(plugin.getDataFolder().getPath(), path);
      folder.mkdirs();

      File languageFile = new File(folder, name);

      extractFile(is, languageFile);
    } catch (IOException e) {
      LightPoles.log("# could not extract file: " + name, new Object[0]);
      return false;
    }
    LightPoles.log("# extracted file: " + name, new Object[0]);
    return true;
  }