Here you can find the source of toUnderscore(String v)
Parameter | Description |
---|---|
v | a parameter |
public static String toUnderscore(String v)
//package com.java2s; //License from project: Apache License public class Main { /**/* w w w . j a va2 s .co m*/ * userName -> user_name * Password -> _password * @param v * @return */ public static String toUnderscore(String v) { StringBuilder sb = new StringBuilder(); char[] chars = v.toCharArray(); // 65-90 A-Z // 97-112 a-z for (char ch : chars) { if (ch >= 65 && ch <= 90) { sb.append("_"); } sb.append(Character.toLowerCase(ch)); } return sb.toString(); } }