public class FormatExtensions extends Object
Modifier and Type | Method and Description |
---|---|
static String[] |
allImageExtensions()
The extensions of all image file formats as enumerated in
ImageFileFormat . |
static Path |
changeExtension(Path path,
NonImageFileFormat formatToChangeFrom,
FileFormat formatToAssign)
Change the extension in a path.
|
static boolean |
matches(String filePath,
String extensionWithoutLeadingPeriod)
Does a filePath match an extension?
|
static String |
normalizeToLowerCase(String extension)
Normalize an extension to lower-case.
|
static String |
removeAnyLeadingPeriod(String str)
Removes a single leading period from a string, if one exists.
|
public static String[] allImageExtensions()
ImageFileFormat
.
Note that some formats may have more than one extension e.g. tif
and tiff
.
public static boolean matches(String filePath, String extensionWithoutLeadingPeriod)
filePath
- file-path to match, case irrelevantextensionWithoutLeadingPeriod
- the extension to match (in lower-case, without a leading
period)public static Path changeExtension(Path path, NonImageFileFormat formatToChangeFrom, FileFormat formatToAssign) throws OperationFailedException
path
- the path to change if the extension matchesformatToChangeFrom
- the format to change from (a match occurs against the associated
extension)formatToAssign
- the format to assign (the default extension is assigned)OperationFailedException
- if the unchanged path does not match formatToChangeFrom
.public static String removeAnyLeadingPeriod(String str)
str
- a string that may or may not have a leading period.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.