From c7bcce309b6a8c5856726cd88bab5c61556aec95 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 20 Jan 2022 14:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=86=E7=A0=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E8=8E=B7=E5=8F=96=E6=8B=BC=E9=9F=B3=E5=87=BA?= =?UTF-8?q?=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yutou/tools/ToolsApplication.java | 2 +- src/main/java/com/yutou/tools/utils/Tools.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) 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 ""; }