/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package test; import java.io.IOException; import org.apache.commons.lang.StringUtils; public class StripTest { public static void main(String[] args) throws IOException { String str1 = "\n\tThis is my string "; System.out.println("Original String:"); System.out.println("[" + str1 + "]"); System.out.println("Stripped String via StringUtils.strip(str1):"); System.out.println("[" + StringUtils.strip(str1) + "]"); System.out.println(); String str2 = " , . ! This is another string \t , ."; System.out.println("Original String:"); System.out.println("[" + str2 + "]"); System.out.println("Stripped String via StringUtils.strip(str2, \" \\t,.\"):"); System.out.println("[" + StringUtils.strip(str2, " \t,.") + "]"); } }