【String处理】-- 下划线字符串转驼峰

  private static Pattern linePattern = Pattern.compile("_(\\w)");

  /**
   * 下划线转驼峰
   */
  public static String lineToHump(String str) {
    str = str.toLowerCase();
    Matcher matcher = linePattern.matcher(str);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
      matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
    }
    matcher.appendTail(sb);
    return sb.toString();
  }

 

转载于:https://my.oschina.net/u/3532010/blog/3068308

你可能感兴趣的:(【String处理】-- 下划线字符串转驼峰)