diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index bb5f812..aa197c8 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ToolsApplication { - public static final String version="1.4.3"; + public static final String version="1.4.4.1"; public static void main(String[] args) { System.out.println("当前版本号:" + version); diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java index e47299a..41f137d 100644 --- a/src/main/java/com/yutou/tools/utils/Tools.java +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -456,14 +456,10 @@ public class Tools { } public static String getPinYin(String text) { - try { - String pinyin = HttpTools.get("http://api.tianapi.com/pinyin/index?key=a1e0f7267037c4e0ea02fb1cb3912367&text=" + URLEncoder.encode(text, "UTF-8")); - JSONObject json = JSONObject.parseObject(pinyin); - if (json.getInteger("code") == 200) { - return json.getJSONObject("newslist").getString("pinyin").trim().replace(" ", ""); - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + String pinyin = HttpTools.get("http://api.tianapi.com/pinyin/index?key=a1e0f7267037c4e0ea02fb1cb3912367&text=" + URLEncoder.encode(text, StandardCharsets.UTF_8)); + JSONObject json = JSONObject.parseObject(pinyin); + if (json.getInteger("code") == 200) { + return json.getJSONArray("newslist").getJSONObject(0).getString("pinyin").trim().replace(" ", ""); } return ""; }