2014-09-05 50 views

回答

55

Guava通过其CaseFormat类支持此

import com.google.common.base.CaseFormat; 


public class StackOverflow25680258 { 

    public static void main(String[] args) { 
     System.out.println(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, "input_in_snake_case")); 
    } 

} 

输出

InputInSnakeCase 
+0

我有同样的问题。但如果单词是helloFunnyWORLD,结果应该是hello-funny-world。番石榴解决方案不适合我。 – 2017-06-02 20:15:08

+0

出于好奇,为什么是类名'StackOverflow25680258'?你有某种宏吗? – SureshS 2018-03-02 10:30:30

相关问题