Java中的CaseFormat类
CaseFormat类是用于在各种ASCII大小写格式之间进行转换的实用程序类-
覆盖Cloneable。
重写equals。
格式的专业化。
格式的特殊化。
格式的专业化。
格式的特殊化。
示例
现在让我们看一个使用Java文件GuavaTester.java实现CaseFormat类的示例-
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
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短