java获得汉语首字母】的更多相关文章

package org.scbit.lsbi.scp.utils; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPi…
java string,需要进行首字母大写改写,网上大家的思路基本一致,就是将首字母截取,转化成大写然后再串上后面的,类似如下代码 //首字母大写     public static String captureName(String name) {         name = name.substring(0, 1).toUpperCase() + name.substring(1);        return  name;           } 将字符串name 转化为首字母大写.但是…
有时候,可能会有一些类似这样的需求: 对于这样的效果,我们可以有类似这样的解决方案: package bys.utils; import java.io.UnsupportedEncodingException; /** * Created by toutou on 2014/2/21 */ public class ChineseCharacterHelper { static final int GB_SP_DIFF = 160; // 存放国标一级汉字不同读音的起始区位码 static f…
前言 在项目中很多时候我们需要获取姓名或者名称的首字母或者全拼,以用于模糊查询或者字母查询,在这里分享一个实例:供小伙伴们参考. 导入jar包 <dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version> </dependency> 代码 package com.xx…
public class FirstLetterUppercase { public static void main(String[] args){ System.out.println(new FirstLetterUppercase().upperFirstLatter("letter")); System.out.println(new FirstLetterUppercase().upperFirstLatter2("letter"));. } /** *…
C#标准是首字母大写,Java规范是首字母小写,在序列化成Json之后,反序列化会出现反序列化失败的问题.. 从C#反序列化成JavaBean的时候通过如下注解可以直接解决该问题 @JsonNaming(value = PropertyNamingStrategy.UpperCamelCaseStrategy.class) 将该注解放到对应的class上,即可从大写首字母的Json串,反序列化成JavaBean.…
Java 字符串数组首字母排序 字符串数组按首字母排序:(区分大小写) String[] strings = new String[]{"ba","aa","CC","Ba","DD","ee","dd"}; Arrays.sort(strings); for (int i = 0; i < strings.length; i++) { System.out.p…
import java.util.*; import net.sourceforge.pinyin4j.PinyinHelper;import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;impo…
原理: GB2312编码中的中文是按照拼音排序的 注意: 一些生僻的字无法获得正确的首字母,原因是这些字都是后加入的. import java.io.UnsupportedEncodingException; /** * 取得给定汉字串的首字母串,即声母串 * * 注:只支持GB2312字符集中的汉字 */ class ChineseInital { private final static int[] areaCode = { 1601, 1637, 1833, 2078, 2274, 230…
在项目中要更能根据某些查询条件(比如姓名)的首字母作为条件进行查询,比如查一个叫"李晓明"的人,可以输入'lxm'.写了一个工具类如下: import java.io.UnsupportedEncodingException; /** * 取得给定汉字串的首字母串,即声母串 * Title: ChineseCharToEn * @date 2004-02-19 注:只支持GB2312字符集中的汉字 */ public final class ChineseCharToEn { priv…