将如下这段php代码用java怎么实现。function escapeForXML ($input) {
    $patterns = array(
                    "/\s+/",
                    "/[\x-\x8\xb-\xc\xe-\x1f]/", //escape invalid Unicode in XML
                    "/<.*?>/"  //remove html tag
                );
    $replace = array(
                   " ",
                   " ",
                   ""
               );
    $output .= preg_replace($patterns, $replace, $input);
    return trim(htmlspecialchars($output));
}