Here you can find the source of countChars(String s, String charset)
public static int countChars(String s, String charset)
//package com.java2s; //License from project: CDDL license public class Main { public static int countChars(String s, String charset) { int nc = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (charset.indexOf(c) >= 0) nc++;// ww w . j av a 2s. c o m } return nc; } }