Skip to content

Commit bc4e251

Browse files
committed
EDIT: Added cut parent method.
1 parent 934c024 commit bc4e251

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/main/java/jce/util/PathHelper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public String append(String... paths) {
4040
}
4141
}
4242

43+
/**
44+
* Cuts the first parent from a path.
45+
* @param path is the path.
46+
* @return the cut path, or the original if it has no parents.
47+
*/
48+
public String cutParent(String path) {
49+
if (path.contains(Character.toString(separator))) {
50+
return path.substring(path.indexOf(separator) + 1);
51+
}
52+
return path;
53+
}
54+
4355
/**
4456
* Returns the name of the original path. That is the last segment of the original path.
4557
* @param path is the original path.

0 commit comments

Comments
 (0)