Java - Write code to Remove all whitespaces and non visible characters such as tab, \n. using regex

Requirements

Write code to Remove all whitespaces and non visible characters such as tab, \n. using regex

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(removeAllSpace(str));
    }/*from   ww w  . j  a  v  a2 s  . com*/

    /**
     * Remove all whitespaces and non visible characters such as tab, \n.
     * 
     * @param str
     * @return String
     */
    public static String removeAllSpace(String str) {
        return str.replaceAll("\\s+", "");
    }
}