package jp.ac.osaka_u.sanken.util; import java.util.ArrayList; import java.util.List; public class StringUtil { /** * 文字列を読点で区切ってhtml文字列に変換する * @param str * @return */ public static String makeHtmlString(String str){ return makeHtmlString(splitString(str)); } /** * 文字列をhtml文字列に変換する * @param strs * @return */ public static String makeHtmlString(String[] strs){ StringBuilder sb = new StringBuilder(); sb.append(""); for (int i=0; i"); } } sb.append(""); return sb.toString(); } /** * 文字列を読点で分割する * @param str * @return */ public static String[] splitString(String str){ String[] ret; ret = splitString(str, "。"); ret = splitString(ret, "\\. "); return ret; } private static String[] splitString(String str, String sep){ return splitString(new String[]{str}, sep); } private static String[] splitString(String[] strs, String sep){ List ret = new ArrayList(); String sepTmp = sep.replace("\\", ""); for (String str : strs){ boolean endSep = str.endsWith(sepTmp); String[] tmps = str.split(sep); for (int i=0; i getPartHitString(List list, String word){ List ret = new ArrayList(); if (list == null){ return ret; } for (String item : list){ if (item.contains(word)){ ret.add(item); } } return ret; } }