You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
package com.fr.plugin.cpic.utils; |
|
|
|
import com.fanruan.api.util.StringKit; |
|
import com.fr.plugin.context.PluginContext; |
|
import com.fr.plugin.context.PluginContexts; |
|
|
|
import java.net.URL; |
|
import java.util.List; |
|
|
|
/** |
|
* 路径工具 |
|
*/ |
|
public class PathUtil { |
|
|
|
/** |
|
* 获取当前插件目录 |
|
* |
|
* @return |
|
* @throws Exception |
|
*/ |
|
public static String getLocalCachePath() throws Exception { |
|
PluginContext contexts = PluginContexts.currentContext(); |
|
List<URL> urls = contexts.getClassPaths(); |
|
String classPath = ""; |
|
for (URL url : urls) { |
|
if (url.getPath().contains("classes")) { |
|
classPath = StringKit.subStringByByteLength(url.getPath(), "UTF-8", url.getPath().indexOf("classes")); |
|
} |
|
} |
|
return classPath; |
|
} |
|
|
|
/** |
|
* 获取后缀名 |
|
* |
|
* @param fileName |
|
* @return |
|
*/ |
|
public static String getLastName(String fileName) { |
|
String[] split = fileName.split("\\."); |
|
if (split.length > 1) { |
|
return split[split.length - 1]; |
|
} else { |
|
return ""; |
|
} |
|
} |
|
|
|
}
|
|
|