Package nl.talsmasoftware.umldoclet.util
Class FileUtils
java.lang.Object
nl.talsmasoftware.umldoclet.util.FileUtils
Contains static utility methods for files.
- Author:
- Sjoerd Talsma
-
Method Summary
Modifier and TypeMethodDescriptionstatic FileensureParentDir(File file) Ensure that the parent directory exists for the specified file.static StringfileNameOf(String path) Shortcut implementation that determines the substring after the last Windows or *nix path separator.static booleanhasExtension(Object file, String extension) static ReaderopenReaderTo(String basedir, URI uri, String charsetName) Opens a reader to the specified URI.static StringrelativePath(File from, File to) Returns the relative path from one file to another.static StringwithoutExtension(String path)
-
Method Details
-
relativePath
Returns the relative path from one file to another.- Parameters:
from- The source file.to- The target file.- Returns:
- The relative path from the source to the target file.
-
ensureParentDir
Ensure that the parent directory exists for the specified file.This will attempt to create the parent directory if it does not exist yet.
- Parameters:
file- The file verify directory existence for.- Returns:
- The specified file.
- Throws:
IllegalStateException- in case the parent directory did not yet exist and could not be created either.
-
fileNameOf
Shortcut implementation that determines the substring after the last Windows or *nix path separator.- Parameters:
path- The path to return filename of.- Returns:
- The part of the specified part after the last slash or backslash.
-
withoutExtension
-
openReaderTo
Opens a reader to the specified URI.If the call
uri.toURL().openStream()succeeds, a reader is wrapped and returned. Otherwise, if the URI is absolute, an attempt is made to open it as a file. If this also fails, a last effort is made to open the uri relative to the specifiedbasedirdirectory.- Parameters:
basedir- The base directory to use if the URI turns out to be a relative file link.uri- The URI to read from.charsetName- The character set to use for reading.- Returns:
- The opened reader.
- Throws:
IOException- in case the call touri.toURL().openStream()threw an I/O Exception.
-
hasExtension
-