| 1 | package fr.sii.ogham.core.util; | |
| 2 | ||
| 3 | import java.nio.file.Path; | |
| 4 | import java.util.StringJoiner; | |
| 5 | ||
| 6 | /** | |
| 7 | * Utility class to handle resources | |
| 8 | * | |
| 9 | * @author Aurélien Baudet | |
| 10 | * | |
| 11 | */ | |
| 12 | public final class ResourceUtils { | |
| 13 | /** | |
| 14 | * Convert a path that is dependent on OS to a resource path (using slashes). | |
| 15 | * | |
| 16 | * @param path the path to convert | |
| 17 | * @return the converted path | |
| 18 | */ | |
| 19 | public static String toResourcePath(Path path) { | |
| 20 | StringJoiner joiner = new StringJoiner("/", path.startsWith("/") ? "/" : "", path.endsWith("/") ? "/" : ""); | |
| 21 | path.forEach(p -> joiner.add(p.toString())); | |
| 22 | return joiner.toString(); | |
| 23 | } | |
| 24 | ||
| 25 | private ResourceUtils() { | |
| 26 | super(); | |
| 27 | } | |
| 28 | } | |
Mutations | ||
| 30 |
1.1 |
|
| 45 |
1.1 |
|
| 58 |
1.1 |
|
| 59 |
1.1 |
|
| 62 |
1.1 |