From ee17b27a7924aab5fb91e668d3f6a21af0bf30fb Mon Sep 17 00:00:00 2001 From: hyb1996 <946994919@qq.com> Date: Sat, 8 Sep 2018 09:20:23 +0800 Subject: [PATCH] fix: files.create() cannot create dir --- common/src/main/java/com/stardust/pio/PFiles.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/stardust/pio/PFiles.java b/common/src/main/java/com/stardust/pio/PFiles.java index 2ca2f4f0..5f2dfc2b 100644 --- a/common/src/main/java/com/stardust/pio/PFiles.java +++ b/common/src/main/java/com/stardust/pio/PFiles.java @@ -56,10 +56,15 @@ public class PFiles { } public static boolean create(String path) { - try { - return new File(path).createNewFile(); - } catch (IOException e) { - return false; + File f = new File(path); + if (path.endsWith(File.separator)) { + return f.mkdir(); + } else { + try { + return f.createNewFile(); + } catch (IOException e) { + return false; + } } }