Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static String getClassNameFromTableName(String tableName) {
        Pattern p = Pattern.compile("(_+|^)(\\w?)");
        Matcher m = p.matcher(tableName);
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            m.appendReplacement(sb, m.group(2).toUpperCase());
        }
        m.appendTail(sb);

        return sb.toString();
    }
}