Guava教程

Guava CaseFormat类

CaseFormat是一种实用工具类,以提供不同的ASCII字符格式之间的转换。

类声明

以下是com.google.common.base.CaseFormat类的声明:

@GwtCompatible
public enum CaseFormat
   extends Enum<CaseFormat>

枚举常量

方法

继承的方法

这个类继承了以下类方法:java.lang.Enum  java.lang.Object

CaseFormat 示例

使用所选择的编辑器创建下面的java程序 C:/> Guava

GuavaTester.java

import com.google.common.base.CaseFormat;

public class GuavaTester {
   public static void main(String args[]){
      GuavaTester tester = new GuavaTester();
      tester.testCaseFormat();
   }

   private void testCaseFormat(){
      String data = "test_data";
      System.out.println(CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, "test-data"));
      System.out.println(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "test_data"));
      System.out.println(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, "test_data"));
   }
}

验证结果

使用javac编译器编译如下类

C:\Guava>javac GuavaTester.java

现在运行GuavaTester看到的结果

C:\Guava>java GuavaTester

看到结果

testData
testData
TestData

 

 

 

 

转载自并发编程网-ifeve.com

全部教程