Here you can find the source of cleanText(String text)
public static String cleanText(String text)
//package com.java2s; // Licensed under both the CeCILL-B and the Apache License, Version 2.0 public class Main { public static String cleanText(String text) { //clean text String result = text.replaceAll("[\"()\n]", " "); //remove multiple spaces beginning and end result = result.trim();//from www . j a va2 s .co m //remove multiple spaces within the string result = result.replaceAll("( )+", " "); return result; } }