* added file create helper function
This commit is contained in:
parent
c3895a5852
commit
e08fd8799b
@ -243,6 +243,10 @@ public class ScriptShellMethods {
|
|||||||
return FileUtilities.copyAs(self, new File(destination, self.getName()));
|
return FileUtilities.copyAs(self, new File(destination, self.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void createFileIfNotExists(File self) throws IOException {
|
||||||
|
FileUtilities.createFileIfNotExists(self);
|
||||||
|
}
|
||||||
|
|
||||||
public static File relativize(File self, File other) throws IOException {
|
public static File relativize(File self, File other) throws IOException {
|
||||||
return self.getCanonicalFile().toPath().relativize(other.getCanonicalFile().toPath()).toFile();
|
return self.getCanonicalFile().toPath().relativize(other.getCanonicalFile().toPath()).toFile();
|
||||||
}
|
}
|
||||||
|
@ -156,15 +156,12 @@ public final class FileUtilities {
|
|||||||
return org.apache.commons.io.FileUtils.deleteQuietly(file);
|
return org.apache.commons.io.FileUtils.deleteQuietly(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File createFileIfNotExists(File file) throws IOException {
|
public static void createFileIfNotExists(File file) throws IOException {
|
||||||
if (file.isFile()) {
|
if (!file.isFile()) {
|
||||||
return file;
|
// create parent folder structure if necessary & create file
|
||||||
}
|
|
||||||
|
|
||||||
// create parent folder structure if necessary
|
|
||||||
Files.createDirectories(file.getParentFile().toPath());
|
Files.createDirectories(file.getParentFile().toPath());
|
||||||
// create file
|
Files.createFile(file.toPath()).toFile();
|
||||||
return Files.createFile(file.toPath()).toFile();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] readFile(File source) throws IOException {
|
public static byte[] readFile(File source) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user