Java

  1. google spreadsheet csv redirect problem
  2. autocompletion texteditor for java
  3. maven
  4. logback
  5. bazaar
  6. java dom xhtml
  7. singleton
  8. diff-util
  9. MineMessage.GetContent() Error
  10. h2 database
  11. google appengine memo
  12. java decompiler
  13. google app engine sdk run as web application, no such field defaultZoneTL bug
  14. 2015年5月、Oracle Java SE7 Gold合格に関して
  15. Java静的メソッド、クラス変数、インスタンス変数の説明

java diversous

hash map iterator

Iterator it = map.keySet().iterator();
while (it.hasNext()) {
            Object o = it.next();
            System.out.println(o + " = " + map.get(o));
}

利用例 hashmapのキーを引き回して関連記事がないか走査する

    private String getrelate(final String title)
    {
        final StringBuilder sbr = new StringBuilder();
        final Pattern p = Pattern.compile("^[a-zA-Z0-9]+");
        final Matcher m = p.matcher(title);
        final String cat = (m.find()) ? m.group() : "";
        if (cat.equals(""))
        {
            return "";
        }
        final Iterator it = hm.keySet().iterator();
        while (it.hasNext())
        {
            final Object o = it.next();
            final String s = ((String) o);
            if (s.startsWith(cat) && !s.equals(title))
            {
                final String t = s.substring(cat.length());
                if (t.startsWith(" ") | t.matches("^[^a-zA-Z].*") | s.equals(cat))
                {
                    try
                    {
                        sbr.append("  <a href=\"" + md5sum.md5sum(s.getBytes()) + ".html\">" + s + "</a>  ");
                    }
                    catch (final NoSuchAlgorithmException e)
                    {
                        e.printStackTrace();
                    }
                }
            }
        }
        final String related = (sbr.length() > 0) ? "<div class=\"related\">関連:  " + sbr.toString() + "</div>" : "";
        return related;
    }
   HashMap<String, String> hm = new HashMap<String, String>();
    last modified: 16 July 2016 [ View wiki source Close ]
     
SEARCH DIFFERENCE ATTACHMENT RECENT POST