| | |
| | | * @return the relative path
|
| | | */
|
| | | public static String getRelativePath(String basePath, String fullPath) {
|
| | | String relativePath = fullPath.substring(basePath.length()).replace('\\', '/');
|
| | | if (relativePath.charAt(0) == '/') {
|
| | | relativePath = relativePath.substring(1);
|
| | | String bp = basePath.replace('\\', '/').toLowerCase();
|
| | | String fp = fullPath.replace('\\', '/').toLowerCase();
|
| | | if (fp.startsWith(bp)) {
|
| | | String relativePath = fullPath.substring(basePath.length()).replace('\\', '/');
|
| | | if (relativePath.charAt(0) == '/') {
|
| | | relativePath = relativePath.substring(1);
|
| | | }
|
| | | return relativePath;
|
| | | }
|
| | | return relativePath;
|
| | | return fullPath;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | return path;
|
| | | }
|
| | | |
| | | /**
|
| | | * Variation of String.matches() which disregards case issues.
|
| | | * |
| | | * @param regex
|
| | | * @param input
|
| | | * @return true if the pattern matches
|
| | | */
|
| | | public static boolean matchesIgnoreCase(String input, String regex) {
|
| | | Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
| | | Matcher m = p.matcher(input);
|
| | | return m.matches();
|
| | | }
|
| | | } |