public class RemoveTrailingSeparator {
public static void main(String[] args) {
String path = "c:/example/path/";
// Check if the string ends with a path separator
if (path.endsWith("/") || path.endsWith("\\")) {
// Remove the trailing separator
path = path.substring(0, path.length() - 1);
}
System.out.println(path);
}
}
/*
run:
c:/example/path
*/