Class FilteringUtils
- java.lang.Object
-
- org.apache.maven.shared.filtering.FilteringUtils
-
public final class FilteringUtils extends Object
- Author:
- Olivier Lamy, Dennis Lundberg
-
-
Field Summary
Fields Modifier and Type Field Description static intCOPY_BUFFER_LENGTH
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcopyFile(File from, File to, String encoding, FilterWrapper[] wrappers)If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.static voidcopyFile(File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite)Deprecated.usecopyFile(File, File, String, FilterWrapper[])insteadstatic StringescapeWindowsPath(String val)static StringgetRelativeFilePath(String oldPath, String newPath)This method can calculate the relative path between two paths on a file system.static FileresolveFile(File baseFile, String filename)Resolve a filefilenameto its canonical form.
-
-
-
Field Detail
-
COPY_BUFFER_LENGTH
public static final int COPY_BUFFER_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
escapeWindowsPath
public static String escapeWindowsPath(String val)
- Parameters:
val- The value to be escaped.- Returns:
- Escaped value
-
resolveFile
public static File resolveFile(File baseFile, String filename)
Resolve a filefilenameto its canonical form. Iffilenameis relative (doesn't start with/), it is resolved relative tobaseFile. Otherwise it is treated as a normal root-relative path.- Parameters:
baseFile- where to resolvefilenamefrom, iffilenameis relativefilename- absolute or relative file path to resolve- Returns:
- the canonical
Fileoffilename
-
getRelativeFilePath
public static String getRelativeFilePath(String oldPath, String newPath)
This method can calculate the relative path between two paths on a file system.
PathTool.getRelativeFilePath( null, null ) = "" PathTool.getRelativeFilePath( null, "/usr/local/java/bin" ) = "" PathTool.getRelativeFilePath( "/usr/local", null ) = "" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin/" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local/java/bin", "/usr/local/" ) = "../.." PathTool.getRelativeFilePath( "/usr/local/", "/usr/local/java/bin/java.sh" ) = "java/bin/java.sh" PathTool.getRelativeFilePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = "../../.." PathTool.getRelativeFilePath( "/usr/local/", "/bin" ) = "../../bin" PathTool.getRelativeFilePath( "/bin", "/usr/local/" ) = "../usr/local"
Note: On Windows based system, the/character should be replaced by\character.- Parameters:
oldPath- old pathnewPath- new path- Returns:
- a relative file path from
oldPath.
-
copyFile
public static void copyFile(File from, File to, String encoding, FilterWrapper[] wrappers) throws IOException
If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.- Parameters:
from- the file to copyto- the destination fileencoding- the file output encoding (only if wrappers is not empty)wrappers- array ofFilterWrapper- Throws:
IOException- if an IO error occurs during copying or filtering
-
copyFile
@Deprecated public static void copyFile(File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite) throws IOException
Deprecated.usecopyFile(File, File, String, FilterWrapper[])insteadIf wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.- Parameters:
from- the file to copyto- the destination fileencoding- the file output encoding (only if wrappers is not empty)wrappers- array ofFilterWrapperoverwrite- unused- Throws:
IOException- if an IO error occurs during copying or filtering
-
-