Here you can find the source of removeSpecialChars(final String word)
public static List<String> removeSpecialChars(final String word)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> removeSpecialChars(final String word) { // Utility to generate only alpha-numeric tokens from the word. if (word.length() == 0) return null; final List<String> tokenList = new ArrayList<String>(); String token = ""; for (int index = 0; index < word.length(); index++) { char ch = word.charAt(index); if (('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9')) token += ch;//w w w . j a va 2s. c o m else if (token.trim().length() != 0) { tokenList.add(token); token = ""; } } if (token.length() != 0) tokenList.add(token); return tokenList; } }