From b75e42dac393c699d3f9b528d6e0909ea4d22164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=9A=E6=98=86?= Date: Thu, 3 Mar 2022 16:58:58 +0800 Subject: [PATCH] createFile function throws IOException. --- .../doric/src/main/java/pub/doric/shader/TextNode.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java b/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java index b0d1990f..162b94b0 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/TextNode.java @@ -267,11 +267,9 @@ public class TextNode extends ViewNode { try { String filePath; filePath = getContext().getCacheDir().getPath() + File.separator + "DoricTextFonts"; - String fileName = URLEncoder.encode(type + identifier, "UTF-8"); + String fileName = URLEncoder.encode(type + "_" + identifier, "UTF-8"); if (TextUtils.isEmpty(fileName)) { fileName = (identifier == null) ? "tempFont.ttf" : identifier; - } else { - fileName = fileName + ".ttf"; } File file = createFile(fontData, filePath, fileName); if (file == null) { @@ -461,8 +459,8 @@ public class TextNode extends ViewNode { private static File createFile(byte[] bfile, String filePath,String fileName) throws IOException { BufferedOutputStream bos = null; FileOutputStream fos = null; - File file = null; try { + File file = null; File dir = new File(filePath); if(!dir.exists()){ dir.mkdirs(); @@ -475,6 +473,7 @@ public class TextNode extends ViewNode { fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); bos.write(bfile); + return file; } catch (Exception e) { e.printStackTrace(); throw e; @@ -494,7 +493,6 @@ public class TextNode extends ViewNode { } } } - return file; } @Override