Example usage for java.util HashSet isEmpty

List of usage examples for java.util HashSet isEmpty

Introduction

In this page you can find the example usage for java.util HashSet isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:de.uni_potsdam.hpi.bpt.promnicat.persistenceApi.orientdbObj.index.IndexIntersection.java

/**
 * Load the intersecting referenced objects from the specified indices.
 * First load the database ids from all indices, intersect them, and load the remaining ids.
 * //  w w w  .  j a v a  2s . co m
 * @return the resulting {@link IndexCollectionElement}s
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public Collection<IndexCollectionElement<V>> load() {

    //load dbIds only and sort them by result set size
    TreeList rawResults = new TreeList(); //no generics possible
    int maxSize = 0;
    for (AbstractIndex index : indices) {
        ResultSet<V> oneResultSet = new ResultSet<V>(index.loadIdsOnly(), index.getName());
        rawResults.add(oneResultSet);
        maxSize = Math.max(maxSize, oneResultSet.getSize());
    }

    // create a list of intersecting dbIds
    // start with the smallest result set and intersect with the second smallest, intersect this result with the third smallest a.s.o.
    HashSet<String> intersectingDbIds = new HashSet<String>(maxSize);
    for (Object r : rawResults) {
        ResultSet<V> aResult = (ResultSet<V>) r;

        if (intersectingDbIds.isEmpty()) {
            intersectingDbIds.addAll(aResult.getDbIds());
        } else {
            intersectingDbIds.retainAll(aResult.getDbIds());
        }

        if (intersectingDbIds.isEmpty()) {
            break;
        }
    }

    //create Map of IndexElements each, i.e. group by referenced id. Every group is stored in a IndexCollectedElement
    HashMap<String, IndexCollectionElement<V>> finalElements = new HashMap<String, IndexCollectionElement<V>>(
            indices.size());
    for (Object r : rawResults) {
        ResultSet<V> aResult = (ResultSet<V>) r;
        for (IndexElement indexElement : aResult.getList()) {
            String currentString = indexElement.getDbId();
            if (intersectingDbIds.contains(currentString)) {
                if (!finalElements.containsKey(currentString)) {
                    finalElements.put(currentString, new IndexCollectionElement<V>(currentString));
                }
                finalElements.get(currentString).addIndexElements(indexElement);
            }
        }
    }

    //load pojos
    for (IndexCollectionElement<V> collectionElement : finalElements.values()) {
        collectionElement.loadPojo(papi);
    }

    return finalElements.values();
}

From source file:api.behindTheName.BehindTheNameApi.java

private void Search(final HashSet<String> set, int counter, final PeopleNameOption option,
        final ProgressCallback callback) {
    final int c = counter;
    callback.onProgressUpdate(behindTheNameProgressValues[c]);
    if (!set.isEmpty())
        callback.onProgress(new TreeSet<>(set));

    Platform.runLater(new Runnable() {

        @Override//ww  w  .  ja v  a  2 s . c  om
        public void run() {
            String nation = genres.get(option.genre);
            String gender = getGenderKey(option.gender);
            String url = "http://www.behindthename.com/api/random.php?number=6&usage=" + nation + "&gender="
                    + gender + "&key=" + BEHIND_THE_NAME_KEY;

            final File file = new File("Temp.xml");
            try {
                URL u = new URL(url);
                FileUtils.copyURLToFile(u, file);

                List<String> lines = FileUtils.readLines(file);
                for (String s : lines) {
                    if (s.contains("<name>")) {
                        s = s.substring(s.indexOf(">") + 1, s.lastIndexOf("</"));
                        set.add(s);
                    }
                }

            } catch (MalformedURLException ex) {
                Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
            }

            try {
                Thread.sleep(250);
            } catch (InterruptedException ex) {
                Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (set.size() == MAX_SIZE || c == MAX_SEARCH - 1 || set.isEmpty()) {
                callback.onProgressUpdate(1.0f);

                return;
            }

            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    Search(set, c + 1, option, callback);
                }
            });

        }
    });

}

From source file:eionet.cr.web.util.JstlFunctions.java

/**
 *
 * @param coll/* www .j a v  a2s . c  o m*/
 * @param separator
 * @param sort
 * @param max
 * @return
 */
public static String joinCollection(Collection coll, char separator, boolean sort, int max) {

    if (coll == null || coll.isEmpty()) {
        return "";
    }

    // First, convert the collection objects to set (i.e. excluding duplicates) of strings, using every object's toString(),
    // or if the object is ObjectDTO, then special treatment.
    HashSet<String> set = new HashSet<String>();
    for (Object object : coll) {

        if (object != null) {
            String str = null;
            if (object instanceof ObjectDTO) {
                ObjectDTO objectDTO = (ObjectDTO) object;
                str = objectDTO.getValue();
                if (!objectDTO.isLiteral()) {
                    str = URIUtil.extractURILabel(str, str);
                }
            } else {
                str = object.toString();
            }
            if (StringUtils.isNotBlank(str)) {
                set.add(str);
            }
        }
    }

    // If set empty, then return.
    if (set.isEmpty()) {
        return "";
    }

    // Now convert the set to list.
    List<String> list = new ArrayList<String>(set);

    // If sorting requested, then do so.
    if (sort) {
        Collections.sort(list);
    }

    // Get first "max" elements if max is > 0 and smaller than list size
    if (max > 0 && max < list.size()) {
        list = list.subList(0, max);
        list.add("...");
    }

    // Finally, join the result by separator.
    return StringUtils.join(list, separator);
}

From source file:org.walkmod.conf.providers.yml.AddModulesYMLAction.java

@Override
public void doAction(JsonNode node) throws Exception {
    ArrayNode aux = null;//from   w  w  w .  ja v a  2  s . c om
    HashSet<String> modulesToAdd = new HashSet<String>(modules);
    if (node.has("modules")) {
        JsonNode list = node.get("modules");
        Iterator<JsonNode> it = list.iterator();

        while (it.hasNext()) {
            JsonNode next = it.next();
            modulesToAdd.remove(next.asText().trim());

        }
        if (!modulesToAdd.isEmpty()) {
            if (list.isArray()) {
                aux = (ArrayNode) list;
            }
        }
    } else {
        aux = new ArrayNode(provider.getObjectMapper().getNodeFactory());
    }
    if (!modulesToAdd.isEmpty()) {
        for (String moduleToAdd : modulesToAdd) {
            TextNode prov = new TextNode(moduleToAdd);
            aux.add(prov);
        }
        ObjectNode auxNode = (ObjectNode) node;
        auxNode.set("modules", aux);
        provider.write(node);
    }

}

From source file:de.da_sense.moses.client.com.requests.RequestSendSurveyAnswers.java

/**
 * Constructs a new {@link RequestSendSurveyAnswers}.
 * @param e the executor//from w w  w. ja v  a 2s  .  c  o m
 * @param sessionID the sesion ID
 * @param apkID apk for which answers are sent
 */
public RequestSendSurveyAnswers(ReqTaskExecutor e, String sessionID, String apkID) {
    j = new JSONObject();
    this.e = e;
    try {
        j.put("MESSAGE", "SURVEY_RESULT");
        j.put("SESSIONID", sessionID);
        j.put("APKID", apkID);
        // setting answers
        for (Form form : InstalledExternalApplicationsManager.getInstance().getAppForId(apkID).getSurvey()
                .getForms())
            for (Question question : form.getQuestions()) {
                int questionType = question.getType();
                if (questionType == Question.TYPE_MULTIPLE_CHOICE) {
                    // extra care for multiple choice answers
                    String answer = question.getAnswer();
                    String newAnswer = "";
                    String[] splits = answer.split(",");
                    HashSet<String> theAnswers = new HashSet<String>();
                    for (String split : splits) {
                        String temp = split.replaceAll(",", "").trim();
                        if (!temp.isEmpty())
                            theAnswers.add(temp);
                    }
                    if (!theAnswers.isEmpty()) {
                        newAnswer = "[";
                        for (String anAnswer : theAnswers)
                            newAnswer = newAnswer + anAnswer + ",";
                        newAnswer = newAnswer.substring(0, newAnswer.length() - 1);
                        newAnswer = newAnswer + "]";
                    }
                    j.put(String.valueOf(question.getId()), newAnswer);
                } else
                    j.put(String.valueOf(question.getId()), question.getAnswer());
            }
    } catch (JSONException ex) {
        e.handleException(ex);
    }
}

From source file:org.quantumbadger.redreader.reddit.prepared.RedditPreparedPost.java

public static void onActionMenuItemSelected(final RedditPreparedPost post, final Activity activity,
        final Action action) {

    switch (action) {

    case UPVOTE:/*from w w  w. j  av  a  2  s. c  o m*/
        post.action(activity, RedditAPI.RedditAction.UPVOTE);
        break;

    case DOWNVOTE:
        post.action(activity, RedditAPI.RedditAction.DOWNVOTE);
        break;

    case UNVOTE:
        post.action(activity, RedditAPI.RedditAction.UNVOTE);
        break;

    case SAVE:
        post.action(activity, RedditAPI.RedditAction.SAVE);
        break;

    case UNSAVE:
        post.action(activity, RedditAPI.RedditAction.UNSAVE);
        break;

    case HIDE:
        post.action(activity, RedditAPI.RedditAction.HIDE);
        break;

    case UNHIDE:
        post.action(activity, RedditAPI.RedditAction.UNHIDE);
        break;

    case DELETE:
        new AlertDialog.Builder(activity).setTitle(R.string.accounts_delete).setMessage(R.string.delete_confirm)
                .setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.RedditAction.DELETE);
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();
        break;

    case REPORT:

        new AlertDialog.Builder(activity).setTitle(R.string.action_report)
                .setMessage(R.string.action_report_sure)
                .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.RedditAction.REPORT);
                        // TODO update the view to show the result
                        // TODO don't forget, this also hides
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();

        break;

    case EXTERNAL: {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        String url = (activity instanceof WebViewActivity) ? ((WebViewActivity) activity).getCurrentUrl()
                : post.url;
        intent.setData(Uri.parse(url));
        activity.startActivity(intent);
        break;
    }

    case SELFTEXT_LINKS: {

        final HashSet<String> linksInComment = LinkHandler
                .computeAllLinks(StringEscapeUtils.unescapeHtml4(post.src.selftext));

        if (linksInComment.isEmpty()) {
            General.quickToast(activity, R.string.error_toast_no_urls_in_self);

        } else {

            final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]);

            final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setItems(linksArr, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    LinkHandler.onLinkClicked(activity, linksArr[which], false, post.src);
                    dialog.dismiss();
                }
            });

            final AlertDialog alert = builder.create();
            alert.setTitle(R.string.action_selftext_links);
            alert.setCanceledOnTouchOutside(true);
            alert.show();
        }

        break;
    }

    case SAVE_IMAGE: {

        final RedditAccount anon = RedditAccountManager.getAnon();

        LinkHandler.getImageInfo(activity, post.url, Constants.Priority.IMAGE_VIEW, 0,
                new GetImageInfoListener() {

                    @Override
                    public void onFailure(final RequestFailureType type, final Throwable t,
                            final StatusLine status, final String readableMessage) {
                        final RRError error = General.getGeneralErrorForFailure(activity, type, t, status,
                                post.url);
                        General.showResultDialog(activity, error);
                    }

                    @Override
                    public void onSuccess(final ImgurAPI.ImageInfo info) {

                        CacheManager.getInstance(activity)
                                .makeRequest(new CacheRequest(General.uriFromString(info.urlOriginal), anon,
                                        null, Constants.Priority.IMAGE_VIEW, 0,
                                        CacheRequest.DownloadType.IF_NECESSARY, Constants.FileType.IMAGE, false,
                                        false, false, activity) {

                                    @Override
                                    protected void onCallbackException(Throwable t) {
                                        BugReportActivity.handleGlobalError(context, t);
                                    }

                                    @Override
                                    protected void onDownloadNecessary() {
                                        General.quickToast(context, R.string.download_downloading);
                                    }

                                    @Override
                                    protected void onDownloadStarted() {
                                    }

                                    @Override
                                    protected void onFailure(RequestFailureType type, Throwable t,
                                            StatusLine status, String readableMessage) {
                                        final RRError error = General.getGeneralErrorForFailure(context, type,
                                                t, status, url.toString());
                                        General.showResultDialog(activity, error);
                                    }

                                    @Override
                                    protected void onProgress(boolean authorizationInProgress, long bytesRead,
                                            long totalBytes) {
                                    }

                                    @Override
                                    protected void onSuccess(CacheManager.ReadableCacheFile cacheFile,
                                            long timestamp, UUID session, boolean fromCache, String mimetype) {

                                        File dst = new File(
                                                Environment.getExternalStoragePublicDirectory(
                                                        Environment.DIRECTORY_PICTURES),
                                                General.uriFromString(info.urlOriginal).getPath());

                                        if (dst.exists()) {
                                            int count = 0;

                                            while (dst.exists()) {
                                                count++;
                                                dst = new File(
                                                        Environment.getExternalStoragePublicDirectory(
                                                                Environment.DIRECTORY_PICTURES),
                                                        count + "_" + General.uriFromString(info.urlOriginal)
                                                                .getPath().substring(1));
                                            }
                                        }

                                        try {
                                            final InputStream cacheFileInputStream = cacheFile.getInputStream();

                                            if (cacheFileInputStream == null) {
                                                notifyFailure(RequestFailureType.CACHE_MISS, null, null,
                                                        "Could not find cached image");
                                                return;
                                            }

                                            General.copyFile(cacheFileInputStream, dst);

                                        } catch (IOException e) {
                                            notifyFailure(RequestFailureType.STORAGE, e, null,
                                                    "Could not copy file");
                                            return;
                                        }

                                        activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                                                Uri.parse("file://" + dst.getAbsolutePath())));

                                        General.quickToast(context,
                                                context.getString(R.string.action_save_image_success) + " "
                                                        + dst.getAbsolutePath());
                                    }
                                });

                    }

                    @Override
                    public void onNotAnImage() {
                        General.quickToast(activity, R.string.selected_link_is_not_image);
                    }
                });

        break;
    }

    case SHARE: {

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, post.title);
        mailer.putExtra(Intent.EXTRA_TEXT, post.url);
        activity.startActivity(Intent.createChooser(mailer, activity.getString(R.string.action_share)));
        break;
    }

    case SHARE_COMMENTS: {

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, "Comments for " + post.title);
        mailer.putExtra(Intent.EXTRA_TEXT,
                Constants.Reddit.getUri(Constants.Reddit.PATH_COMMENTS + post.idAlone).toString());
        activity.startActivity(
                Intent.createChooser(mailer, activity.getString(R.string.action_share_comments)));
        break;
    }

    case COPY: {

        ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        manager.setText(post.url);
        break;
    }

    case GOTO_SUBREDDIT: {

        try {
            final Intent intent = new Intent(activity, PostListingActivity.class);
            intent.setData(SubredditPostListURL.getSubreddit(post.src.subreddit).generateJsonUri());
            activity.startActivityForResult(intent, 1);

        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            Toast.makeText(activity, R.string.invalid_subreddit_name, Toast.LENGTH_LONG).show();
        }

        break;
    }

    case USER_PROFILE:
        LinkHandler.onLinkClicked(activity, new UserProfileURL(post.src.author).toString());
        break;

    case PROPERTIES:
        PostPropertiesDialog.newInstance(post.src).show(activity.getFragmentManager(), null);
        break;

    case COMMENTS:
        ((RedditPostView.PostSelectionListener) activity).onPostCommentsSelected(post);
        break;

    case LINK:
        ((RedditPostView.PostSelectionListener) activity).onPostSelected(post);
        break;

    case COMMENTS_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((RedditPostView.PostSelectionListener) activity).onPostCommentsSelected(post);
        break;

    case LINK_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((RedditPostView.PostSelectionListener) activity).onPostSelected(post);
        break;

    case ACTION_MENU:
        showActionMenu(activity, post);
        break;

    case REPLY:
        final Intent intent = new Intent(activity, CommentReplyActivity.class);
        intent.putExtra("parentIdAndType", post.idAndType);
        activity.startActivity(intent);
        break;
    }
}

From source file:abs.backend.erlang.ClassGenerator.java

private void generateExports() {
    ecs.println("-export([get_val_internal/2,set_val_internal/3,init_internal/0,get_all_state/1]).");
    ecs.println("-compile(export_all).");
    ecs.println();/*from w  w  w . j a v  a2 s.  c  o m*/

    HashSet<MethodSig> callable_sigs = new HashSet<MethodSig>();
    HashSet<InterfaceDecl> visited = new HashSet<InterfaceDecl>();
    for (InterfaceTypeUse i : classDecl.getImplementedInterfaceUseList()) {
        visited.add((InterfaceDecl) i.getDecl());
    }

    while (!visited.isEmpty()) {
        InterfaceDecl id = visited.iterator().next();
        visited.remove(id);
        for (MethodSig ms : id.getBodyList()) {
            if (ms.isHTTPCallable()) {
                callable_sigs.add(ms);
            }
        }
        for (InterfaceTypeUse i : id.getExtendedInterfaceUseList()) {
            visited.add((InterfaceDecl) i.getDecl());
        }
    }

    ecs.print("exported() -> #{ ");
    boolean first = true;
    for (MethodSig ms : callable_sigs) {
        if (ms.isHTTPCallable()) {
            if (!first)
                ecs.print(", ");
            first = false;
            ecs.print("<<\"" + ms.getName() + "\">> => { ");
            ecs.print("'m_" + ms.getName() + "'");
            ecs.print(", ");
            ecs.print("<<\"" + ms.getReturnType().getType().getQualifiedName() + "\">>");
            ecs.print(", ");
            ecs.print("[ ");
            boolean innerfirst = true;
            for (ParamDecl p : ms.getParamList()) {
                if (!innerfirst)
                    ecs.print(", ");
                innerfirst = false;
                ecs.print("{ ");
                ecs.print("<<\"" + p.getName() + "\">>");
                ecs.print(", ");
                ecs.print("<<\"" + p.getAccess().getType().getQualifiedName() + "\">>");
                ecs.print(" }");
            }
            ecs.print("] ");
            ecs.print("}");
        }
    }
    ecs.println(" }.");
    ecs.println();
}

From source file:org.fao.geonet.kernel.search.AbstractLanguageSearchOrderIntegrationTest.java

private void assertContainsOnly(String[] titles, String... expectedValues) {
    assertEquals(expectedValues.length, titles.length);
    final List<String> titlesList = Arrays.asList(titles);
    final List<String> expectedList = Arrays.asList(expectedValues);

    HashSet extras = new HashSet(titlesList);
    extras.removeAll(expectedList);/*from www . ja v  a2 s  . c  om*/
    HashSet missing = new HashSet(expectedList);
    missing.removeAll(titlesList);

    if (!extras.isEmpty() || !missing.isEmpty()) {
        throw new AssertionError("Following strings should not be in results: " + extras
                + "\nFollowing strings should have been in" + " results: " + missing);
    }
}

From source file:org.apache.lens.cli.doc.TestGenerateCLIUserDoc.java

@Test
public void generateDoc() throws IOException {
    BufferedWriter bw = new BufferedWriter(new FileWriter(new File(APT_FILE)));
    StringBuilder sb = new StringBuilder();
    sb.append(getCLIIntroduction()).append("\n\n\n");
    List<Class<? extends CommandMarker>> classes = Lists.newArrayList(LensConnectionCommands.class,
            LensDatabaseCommands.class, LensStorageCommands.class, LensCubeCommands.class,
            LensDimensionCommands.class, LensFactCommands.class, LensDimensionTableCommands.class,
            LensNativeTableCommands.class, LensQueryCommands.class, LensLogResourceCommands.class,
            LensSchemaCommands.class);

    for (Class claz : classes) {
        UserDocumentation doc = (UserDocumentation) claz.getAnnotation(UserDocumentation.class);
        if (doc != null && StringUtils.isNotBlank(doc.title())) {
            sb.append("** ").append(doc.title()).append("\n\n  ").append(doc.description()).append("\n\n");
        }/*w  w  w .j ava  2  s  .c o m*/
        sb.append("*--+--+\n" + "|<<Command>>|<<Description>>|\n" + "*--+--+\n");
        TreeSet<Method> methods = Sets.newTreeSet(new Comparator<Method>() {
            @Override
            public int compare(Method o1, Method o2) {
                return o1.getAnnotation(CliCommand.class).value()[0]
                        .compareTo(o2.getAnnotation(CliCommand.class).value()[0]);
            }
        });

        for (Method method : claz.getMethods()) {
            if (method.getAnnotation(CliCommand.class) != null) {
                methods.add(method);
            } else {
                log.info("Not adding " + method.getDeclaringClass().getSimpleName() + "#" + method.getName());
            }
        }
        List<DocEntry> docEntries = Lists.newArrayList();
        for (Method method : methods) {
            CliCommand annot = method.getAnnotation(CliCommand.class);
            StringBuilder commandBuilder = new StringBuilder();
            String sep = "";
            for (String value : annot.value()) {
                commandBuilder.append(sep).append(value);
                sep = "/";
            }
            for (Annotation[] annotations : method.getParameterAnnotations()) {
                for (Annotation paramAnnot : annotations) {
                    if (paramAnnot instanceof CliOption) {
                        CliOption cliOption = (CliOption) paramAnnot;
                        HashSet<String> keys = Sets.newHashSet(cliOption.key());
                        boolean optional = false;
                        if (keys.contains("")) {
                            optional = true;
                            keys.remove("");
                        }
                        if (!keys.isEmpty()) {
                            commandBuilder.append(" ");
                            if (!cliOption.mandatory()) {
                                commandBuilder.append("[");
                            }
                            if (optional) {
                                commandBuilder.append("[");
                            }
                            sep = "";
                            for (String key : keys) {
                                commandBuilder.append(sep).append("--").append(key);
                                sep = "/";
                            }
                            if (optional) {
                                commandBuilder.append("]");
                            }
                            sep = "";
                        }
                        commandBuilder.append(" ")
                                .append(cliOption.help().replaceAll("<", "\\\\<").replaceAll(">", "\\\\>"));
                        if (!cliOption.mandatory()) {
                            commandBuilder.append("]");
                        }
                    }
                }
            }
            docEntries.add(new DocEntry(commandBuilder.toString(),
                    annot.help().replaceAll("<", "<<<").replaceAll(">", ">>>")));
        }
        for (DocEntry entry : docEntries) {
            for (int i = 0; i < entry.getHelp().length; i++) {
                sb.append("|").append(i == 0 ? entry.getCommand() : entry.getCommand().replaceAll(".", " "))
                        .append("|").append(entry.getHelp()[i]).append("|").append("\n");
            }
            sb.append("*--+--+\n");
        }
        sb.append("  <<").append(getReadableName(claz.getSimpleName())).append(">>\n\n===\n\n");
    }
    bw.write(sb.toString());
    bw.close();
}

From source file:de.iteratec.iteraplan.general.PropertiesTest.java

/**
 * tests all .properties files in de/iteratec/iteraplan/presentation/resources for duplicate keys.
 * //  w w  w .  ja  va 2 s  .c o  m
 */
@Test
public void testDuplicateKeys() {

    HashSet<String> errorMessages = new HashSet<String>();

    for (LanguageFile lf : languageFiles) {
        errorMessages.addAll(checkFileForDuplicateKeys(lf.getPath()));
        if (!errorMessages.isEmpty()) {
            fail(StringUtils.join(errorMessages, "\n"));
        }
    }
}