去除字符串的空白

Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(param.getUserName()); param.setUserName(m.replaceAll(""));

    推荐阅读