From a4e9d72d41e8f4a3ed098090980e5b76002c6aca Mon Sep 17 00:00:00 2001 From: xioayue Date: Wed, 29 Jun 2022 23:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E9=92=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/chjyj/szwh/utils/SzFileUtils.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/cn/chjyj/szwh/utils/SzFileUtils.java diff --git a/src/main/java/cn/chjyj/szwh/utils/SzFileUtils.java b/src/main/java/cn/chjyj/szwh/utils/SzFileUtils.java new file mode 100644 index 0000000..497b37f --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/utils/SzFileUtils.java @@ -0,0 +1,30 @@ +package cn.chjyj.szwh.utils; + +import java.io.*; + +/** + * 文件操作工具 + * xy + */ +public class SzFileUtils { + /** + * 读取pem文件信息内容,并返回字符串 + * + * @param filePath + * @return + * @throws Exception + */ + public static String getKeyFromFile(String filePath) throws Exception { + File file = new File(filePath); + InputStream ins = new FileInputStream(file); + BufferedReader br = new BufferedReader(new InputStreamReader(ins)); + String readLine = null; + StringBuffer sb = new StringBuffer(); + while ((readLine = br.readLine()) != null) { + sb.append(readLine); + } + br.close(); + ins.close(); + return new String(sb); + } +} \ No newline at end of file