From c3895a58528358f5b3e453bfcdb8749c60fd08cb Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 25 Mar 2015 05:18:35 +0000 Subject: [PATCH] * added file create helper function --- source/net/filebot/util/FileUtilities.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index 1b621993..8f93232c 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -156,6 +156,17 @@ public final class FileUtilities { return org.apache.commons.io.FileUtils.deleteQuietly(file); } + public static File createFileIfNotExists(File file) throws IOException { + if (file.isFile()) { + return file; + } + + // create parent folder structure if necessary + Files.createDirectories(file.getParentFile().toPath()); + // create file + return Files.createFile(file.toPath()).toFile(); + } + public static byte[] readFile(File source) throws IOException { InputStream in = new FileInputStream(source);