Skip to content

Commit 03296e8

Browse files
Babcock, ScottBabcock, Scott
authored andcommitted
Add information about PathUtils
1 parent 1ed7cd5 commit 03296e8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,29 @@ public class OpctConfig extends SettingsCore<OpctConfig.OpctValues> {
161161
return OpctValues.config;
162162
}
163163
}
164+
```
165+
166+
## PathUtils
167+
168+
The **PathUtils** `getNextPath` method provides a method to acquire the next file path in sequence for the specified base name and extension in the indicated target folder.
169+
170+
```java
171+
172+
/*
173+
* This example gets the next path in sequence for base name `artifact` and extension `txt` in the TestNG output directory.
174+
*
175+
* For purposes of this example, the output directory already contains the following files: `artifact.txt`, `artifact-3.txt`
176+
*/
177+
178+
Path collectionPath = Paths.get(testContext.getOutputDirectory());
179+
// => C:\git\my-project\test-output\Default suite
180+
181+
Path artifactPath;
182+
try {
183+
artifactPath = PathUtils.getNextPath(collectionPath, "artifact", "txt");
184+
// => C:\git\my-project\test-output\Default suite\artifact-4.txt
185+
} catch (IOException e) {
186+
provider.getLogger().info("Unable to get output path; no artifact was captured", e);
187+
return;
188+
}
164189
```

0 commit comments

Comments
 (0)