Development/Java

Fileld명을 테이블 컬럼명으로 바꾸자

폴피드 2013. 4. 6. 16:41

가끔 이런것이 필요할 때가 있다.

userId 를 USER_ID 로 바꾸는 기능.

  1. public class Test {
  2.     public static void main(String[] args) throws Exception {
  3.         String regex = "([a-z])([A-Z])";
  4.         String replacement = "$1_$2";
  5.                 String str = "UserId";
  6.                 String value = "";
  7.                 value = str.replaceAll(regex, replacement).toUpperCase();
  8.                 System.out.println(value);
  9.     }
  10. }

728x90
반응형