コード例 #1
0
  /**
   * Create and return a List of Strings found in the PluginFile.
   *
   * @param pluginFile the pluginFile to be read
   * @return a List of Strings representing the lines of this file
   */
  public static List<String> readPluginFile(final PluginFile pluginFile) throws PluginException {
    if (!pluginFile.exists() || pluginFile.isDirectory()) {
      throw PluginException.create(PluginException.Type.DOES_NOT_EXIST, pluginFile.getFilename());
    }
    List<String> list;
    try {
      list = Files.readAllLines(pluginFile.toPath(), Plugin.CHARSET);

    } catch (IOException | SecurityException e) {
      throw PluginException.create(
          PluginException.Type.FILE_READ_ERROR, e, pluginFile.getFilename());
    }
    return list;
  }
コード例 #2
0
 /**
  * Construct a <tt>Plugin</tt> from the given <tt>PluginFile</tt>. Plugins ignore comments,
  * book-end whitespace, and capitalization.
  *
  * @param pluginFile Plugin File to use
  * @throws PluginException if the plugin does not exist or is empty
  */
 public Plugin(final PluginFile pluginFile) throws PluginException {
   this(readPluginFile(pluginFile), pluginFile.getFilename());
 }