|
@@ -44,11 +44,26 @@ public final class PathUtils {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static Path changeExtension(String path, String extension) {
|
|
public static Path changeExtension(String path, String extension) {
|
|
|
- int index = path.indexOf(".");
|
|
|
|
|
|
|
+ int from = Math.max(0, Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')));
|
|
|
|
|
+ int index = path.substring(from).indexOf(".");
|
|
|
if(-1==index) {
|
|
if(-1==index) {
|
|
|
return Paths.get(path + extension);
|
|
return Paths.get(path + extension);
|
|
|
} else {
|
|
} else {
|
|
|
- return Paths.get(path.substring(0,index) + extension);
|
|
|
|
|
|
|
+ return Paths.get(path.substring(0, from + index) + extension);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static Path changeSuffix(Path path, String extension) {
|
|
|
|
|
+ return changeSuffix(path.toString(), extension);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static Path changeSuffix(String path, String extension) {
|
|
|
|
|
+ int from = Math.max(0, Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')));
|
|
|
|
|
+ int index = path.substring(from).lastIndexOf(".");
|
|
|
|
|
+ if(-1==index) {
|
|
|
|
|
+ return Paths.get(path + extension);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Paths.get(path.substring(0, from + index) + extension);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|