Here you can find the source of removePunctuation(String str)
public static String removePunctuation(String str)
//package com.java2s; import java.util.ArrayList; public class Main { public static String removePunctuation(String str) { char[] chs = str.toCharArray(); ArrayList<Character> list = new ArrayList<Character>(); for (int i = 0; i < chs.length; i++) { if (Character.getType(chs[i]) == 5) { list.add(chs[i]);/* ww w. j av a 2s . co m*/ } } char[] newchs = new char[list.size()]; for (int i = 0; i < newchs.length; i++) { newchs[i] = list.get(i); } return new String(newchs); } }