2010-02-12 countChar java 文字列関係 文字の数を数える。 csvの処理で引用符の数を数えるのに使った。 public static int countChar(String text, char c) { if (text == null) { return 0; } int ret = 0; for (int i = 0; i < text.length(); i++) { if (text.charAt(i) == c) { ret++; } } return ret; }