public final class PathUtils extends Object
getNextPath method to acquire the next file
path in sequence for the specified base name and extension in the indicated target folder. If the target folder
already contains at least one file that matches the specified base name and extension, the algorithm used to select
the next path will always return a path whose index is one more than the highest index that currently exists. (If a
single file with no index is found, its implied index is 1.)
getNextPath
...
/*
* This example gets the next path in sequence for base name `artifact`
* and extension `txt` in the TestNG output directory.
*
* For purposes of this example, the output directory already contains
* the following files: `artifact.txt`, `artifact-3.txt`
*/
Path collectionPath = Paths.get(testContext.getOutputDirectory());
// => C:\git\my-project\test-output\Default suite
Path artifactPath;
try {
artifactPath = PathUtils.getNextPath(collectionPath, "artifact", "txt");
// => C:\git\my-project\test-output\Default suite\artifact-4.txt
} catch (IOException e) {
provider.getLogger().info("Unable to get output path; no artifact was captured", e);
return;
}
...
| Modifier and Type | Class and Description |
|---|---|
static class |
PathUtils.ReportsDirectory
This enumeration contains methods to help build proxy subclass names and select reports directories.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
getBaseDir()
Get project base directory.
|
static Path |
getNextPath(Path targetPath,
String baseName,
String extension)
Get the next available path in sequence for the specified base name and extension in the specified folder.
|
public static Path getNextPath(Path targetPath, String baseName, String extension) throws IOException
targetPath - path to target directory for the next available path in sequencebaseName - base name for the path sequenceextension - extension for the path sequenceIOException - if an I/O error is thrown when accessing the starting file.public static String getBaseDir()
Copyright © 2017. All rights reserved.