opencc4j

2022-08-21 14:05:22 浏览数 (1)

分享一个java简繁转换的库opencc4j

https://github.com/houbb/opencc4j

Group ArtifactId Version

代码语言:javascript复制
<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>opencc4j</artifactId>
    <version>1.7.2</version>
</dependency>

使用起来:

繁简体转换

转为简体

代码语言:javascript复制
String original = "生命不息,奮鬥不止";
String result = ZhConverterUtil.toSimple(original);
Assert.assertEquals("生命不息,奋斗不止", result);

转为繁体

代码语言:javascript复制
String original = "生命不息,奋斗不止";
String result = ZhConverterUtil.toTraditional(original);
Assert.assertEquals("生命不息,奮鬥不止", result);

0 人点赞