Package io.github.erdos.stencil.impl
Class FileHelper
java.lang.Object
io.github.erdos.stencil.impl.FileHelper
File handling utilities.
Some methods may be called from Clojure core.
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
createNonexistentTempFile
(File parent, String prefix, String suffix) static File
createNonexistentTempFile
(String prefix, String suffix) Creates a temporary file that is guaranteed not to exist on file system.static String
static String
static void
forceDelete
(File file) Recursively deletes a directory or a file.static void
forceMkdir
(File directory) Creates a directory.static String
Returns file name without extension part.static String
toUnixSeparatedString
(Path path) Returns a string representation of path with unix separators ("/") instead of the system-dependent separators (which is backslash on Windows).
-
Method Details
-
extension
-
extension
-
removeExtension
Returns file name without extension part.- Returns:
- simple file name without extension.
- Throws:
NullPointerException
- the input is null
-
createNonexistentTempFile
Creates a temporary file that is guaranteed not to exist on file system.- Parameters:
prefix
- file name starts with this filesuffix
- file name ends with this file- Returns:
- a new file object pointing to a non-existing file in temp directory.
-
createNonexistentTempFile
-
forceMkdir
Creates a directory. Recursively creates parent directories too.- Parameters:
directory
- not null dir to create- Throws:
IOException
- on IO errorIllegalArgumentException
- when input is null or already exists
-
forceDelete
Recursively deletes a directory or a file.- Parameters:
file
- to delete, not null- Throws:
NullPointerException
- on null or invalid file
-
toUnixSeparatedString
Returns a string representation of path with unix separators ("/") instead of the system-dependent separators (which is backslash on Windows).- Parameters:
path
- not null path object- Returns:
- string of path with slash separators
- Throws:
IllegalArgumentException
- if path is null
-