Here you can find the source of toIdentifier(String text)
public static String toIdentifier(String text)
//package com.java2s; public class Main { public static String toIdentifier(String text) { String out = ""; if (Character.isDigit(text.charAt(0))) out += "_"; for (int i = 0; i < text.length(); i++) { if (Character.isJavaIdentifierPart(text.charAt(i))) out += text.charAt(i);/* w ww . ja va2 s .co m*/ else if (text.charAt(i) == ' ') out += "_"; } return out; } }