Java Utililty Methods String Strip

List of utility methods to do String Strip

Description

The list of methods to do String Strip are organized into topic(s).

Method

StringcollectionToString(Collection collection, boolean stripPackageNames)
Creates a string representation of the given argument array.
return collectionToString(collection, stripPackageNames, null);
Stringstrip(final String s)
Strips undisplayable characters from the String
return strip(s, false, HANDLE_UNKNOWN_INCLUDE);
String[]strip(String string, String token)
strip
StringTokenizer st = new StringTokenizer(string, token);
List<String> result = new ArrayList<String>();
while (st.hasMoreTokens()) {
    result.add((String) st.nextElement());
return result.toArray(new String[0]);
StringstripBadHTMLTags(String s)
strip Bad HTML Tags
final StringBuffer buf = new StringBuffer(s);
final Vector quotes = new Vector();
int i = -1;
int start = -1;
StringBuffer bit = null;
String lastTag = null;
while ((++i) < buf.length()) {
    switch (buf.charAt(i)) {
...
StringstripClassFromClassName(String className)
Find the package specifier for a given class name.
int pos = className.lastIndexOf('.');
if (pos > 0) {
    return className.substring(0, pos);
return "";
StringstripExtension(String filename)
strip Extension
final String SEPARATOR = "."; 
final StringTokenizer tokenizer = new StringTokenizer(filename, SEPARATOR);
return tokenizer.nextToken();
StringstripLastElement(String str)
strip Last Element
String last = getLastElement(str);
if (last.length() > 0) {
    int index = str.lastIndexOf(last);
    if (index >= 0) {
        if (index == 0)
            str = "";
        else
            str = str.substring(0, index);
...
StringstripLeadingSlash(String str)
strip Leading Slash
if (!isEmpty(str) && str.startsWith("/")) {
    return str.substring(1);
} else {
    return str;
StringstripNamespaceDeclarations(String xml)
strip Namespace Declarations
if (xml == null) {
    return null;
for (String declaration : declarations) {
    for (;;) {
        int i = xml.indexOf(declaration);
        if (i < 0) {
            break;
...
StringstripTags(final String tagged)
strip Tags
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();