Here you can find the source of stripTags(final String tagged)
Parameter | Description |
---|---|
tagged | a parameter |
public static String stripTags(final String tagged)
//package com.java2s; /******************************************************************************* * Manchester Institute of Biotechnology * University of Manchester/* w ww. j av a 2 s. c o m*/ * Manchester M1 7ND * United Kingdom * * Copyright (C) 2013 University of Manchester * * This program is released under the Academic Free License ("AFL") v3.0. * (http://www.opensource.org/licenses/academic.php) *******************************************************************************/ import java.util.*; public class Main { /** * */ private static final String COLLECTION_SEPARATOR = ", "; /** * */ private static final int COLLECTION_SEPARATOR_LENGTH = COLLECTION_SEPARATOR .length(); /** * * @param tagged * @return String */ public static String stripTags(final String tagged) { final StringBuffer stripped = new StringBuffer(); boolean inTag = false; for (int i = 0; i < tagged.length(); i++) { final char c = tagged.charAt(i); if (c == '<') { inTag = true; continue; } if (c == '>') { inTag = false; continue; } if (inTag) { continue; } stripped.append(c); } return stripped.toString().trim(); } /** * * @param values * @return String */ public static String toString(final Collection<?> values) { final StringBuilder builder = new StringBuilder(); for (Object value : values) { builder.append(value); builder.append(COLLECTION_SEPARATOR); } if (values.size() > 0) { builder.setLength(builder.length() - COLLECTION_SEPARATOR_LENGTH); } return builder.toString(); } }