public class FileUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileUtil.LetterCase
An
enum representing letter cases. |
| Modifier and Type | Method and Description |
|---|---|
static String |
appendPathSeparator(String path)
Appends a path separator of the same type at the last position in the
specified path if it's not already there, or
/ if there are none,
unless the path is blank. |
static String |
formatPath(Path path,
boolean appendSeparator)
|
static String |
formatPath(String path,
boolean appendSeparator)
Formats a file path by converting backslashes to slashes and optionally
appends a slash to the end of the path if it's not already present.
|
static String |
getExtension(String fileName,
FileUtil.LetterCase convertTo,
Locale locale)
Returns the file extension from
fileName or null if
fileName has no extension. |
static int |
getExtensionIndex(String filePath)
Finds the index of the "extension dot" in the specified string.
|
static String |
getPushFolder(TranslationFileSet fileSet,
boolean includeCrowdinPath)
Determines and returns the push file folder by taking
TranslationFileSet.crowdinPath (optionally) and any folders in
TranslationFileSet.baseFileName into account. |
static List<String> |
splitPath(String path,
boolean omitFilename)
Splits a file path into its elements, optionally omitting the filename
(whatever is after the last separator) if there is one.
|
@Nonnull public static List<String> splitPath(@Nullable String path, boolean omitFilename)
path - the file path to split.omitFilename - whether or not to omit the last "element" (after the
last separator).List of folder elements.@Nullable public static String getExtension(@Nullable String fileName, @Nullable FileUtil.LetterCase convertTo, @Nullable Locale locale)
fileName or null if
fileName has no extension.fileName - the file name from which to extract the extension.convertTo - if null makes no letter case change to the
returned String, otherwise converts the extracted
extension (if any) to the corresponding letter case.locale - the Locale to use for letter case conversion.
Defaults to Locale.ROOT if null.null.public static int getExtensionIndex(@Nullable String filePath)
. in the string that is not the last character
and that comes after the last separator.filePath - the file path to process.. or -1 if none could
be found.@Nullable public static String appendPathSeparator(@Nullable String path)
/ if there are none,
unless the path is blank.path - the path to be modified.null if path is
null.@Nullable public static String formatPath(@Nullable String path, boolean appendSeparator)
path - the file path to format.appendSeparator - if true a slash will be appended to the
path if one isn't already there.null if path was
null.@Nonnull public static String getPushFolder(@Nonnull TranslationFileSet fileSet, boolean includeCrowdinPath)
TranslationFileSet.crowdinPath (optionally) and any folders in
TranslationFileSet.baseFileName into account. The resulting path
will use / as a separator and will end with a separator if it has
at least one element.fileSet - the TranslationFileSet for which to find the
Crowdin push folder.includeCrowdinPath - true to include
TranslationFileSet.crowdinPath in the returned path,
false otherwise.TranslationFileSet is placed in the Crowdin root.Copyright © 2024. All rights reserved.