CharSetUtilsTrial.java Source code

Java tutorial

Introduction

Here is the source code for CharSetUtilsTrial.java

Source

/*
Keep B and o = BoB
Squeeze B and o = Borisbbbecker
 */
import org.apache.commons.lang.CharSetUtils;

public class CharSetUtilsTrial {
    public static void main(String[] args) {

        // Keeps only the characters specified
        System.out.println("Keep B and o = " + CharSetUtils.keep("BorisBecker", "Bo")); // BoB

        // Removes specified character repetitions
        System.out.println("Squeeze B and o = " + CharSetUtils.squeeze("BBoooorisbbbecker", "Bo")); // Borisbbbecker

    }
}