Here you can find the source of toText(String content)
Parameter | Description |
---|---|
content | Description of the Parameter |
public static String toText(String content)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .j a v a2 s. c o m * Format the content for search results page * * @param content Description of the Parameter * @return Description of the Return Value */ public static String toText(String content) { if (content == null) { return ""; } StringBuffer sb = new StringBuffer(); boolean gotSpace = false; for (int i = 0; i < content.length(); i++) { // Strip extra spaces, all returns char a = content.charAt(i); if (a == '\r' || a == '\n' || a == '\t' || a == ' ') { //01, 14, 15 if (!gotSpace) { gotSpace = true; sb.append(" "); } } else { sb.append(a); gotSpace = false; } } return sb.toString(); } }