日期:2014-05-20 浏览次数:20620 次
import java.util.regex.Matcher; import java.util.regex.Pattern; public class test { public static void main(String args[]) { int count = 100000 * 100000000; for (int i = 0; i < count; i++) { new test(); System.out.println(i); } } private static String translate(String original) { StringBuffer newStr = new StringBuffer(""); Pattern p = Pattern.compile("[A-Za-z0-9\\s]"); char[] chars = new char[1]; Matcher m; for (int i = 0; i < original.length(); i++) { chars[0] = original.charAt(i); m = p.matcher(new String(chars)); if (!m.matches()) newStr.append(" ").append(original.charAt(i)).append(" "); else newStr.append(original.charAt(i)); } return newStr.toString(); } }