Java examples for Reflection:Property
get Valid Property Name
//package com.java2s; import java.util.Locale; public class Main { public static void main(String[] argv) throws Exception { String inputString = "java2s.com"; System.out.println(getValidPropertyName(inputString)); }//from w w w.j ava 2s . c o m public static String getValidPropertyName(String inputString) { String answer; if (inputString == null) { answer = null; } else if (inputString.length() < 2) { answer = inputString.toLowerCase(Locale.US); } else { if (Character.isUpperCase(inputString.charAt(0)) && !Character.isUpperCase(inputString.charAt(1))) { answer = inputString.substring(0, 1).toLowerCase(Locale.US) + inputString.substring(1); } else { answer = inputString; } } return answer; } }