如何制作专业动漫的免费网站?大学排名中哪些是最佳选择?
摘要:免费网站制作教程,动漫制作专业大学排名,深圳网站建设十强,备案个人网站做淘宝客kettle通过java步骤获取汉字首拼 用途描述 一组数据,需要获取汉字首拼后,输出&
免费网站制作教程,动漫制作专业大学排名,深圳网站建设十强,备案个人网站做淘宝客kettle通过java步骤获取汉字首拼
用途描述
一组数据#xff0c;需要获取汉字首拼后#xff0c;输出#xff1b;
实现效果 添加jar包
pinyin4j-2.5.0.jar
自定义常量数据 Java代码 完整代码#xff1a;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sou…kettle通过java步骤获取汉字首拼
用途描述
一组数据需要获取汉字首拼后输出
实现效果 添加jar包
pinyin4j-2.5.0.jar
自定义常量数据 Java代码 完整代码
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;String nameField;
String pyField;public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{// Lets look up parameters only once for performance reason. // if (first) { nameField name;//getParameter(name); pyField py ; // getParameter(py); firstfalse; }// First, get a row from the default input hop//Object[] r getRow();// If the row object is null, we are done processing.//if (r null) {setOutputDone();return false; }// It is always safest to call createOutputRow() to ensure that your output rows Object[] is large// enough to handle any new fields you are creating in this step.//Object[] outputRow createOutputRow(r, data.outputRowMeta.size());String name get(Fields.In, nameField).getString(r); // Set the value in the output field //String py toFirstChar(name); get(Fields.Out, pyField).setValue(outputRow, py); // putRow will send the row on to the default output hop. //putRow(data.outputRowMeta, outputRow);return true;
}/*** 获取字符串拼音的第一个字母*/
public static String toFirstChar(String chinese){String pinyinStr ;char[] newChar chinese.toCharArray(); //转为单个字符HanyuPinyinOutputFormat defaultFormat new HanyuPinyinOutputFormat();defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);for (int i 0; i newChar.length; i) {if (newChar[i] 128
