public class Path
{
private static String homePath;
public static String getHome()
{
String path = System.getProperty("test.home");
if (path != null) {
return path;
}
String homePath = getProjectPath();
System.setProperty("test.home",homePath);
return homePath;
}
public static String getClassPath(){
String path = System.getProperty("test_class.home");
if (path != null) {
return path;
}
String homePath = new SysConfigPath().getClass().getResource("").getFile();
String packpath = "aygl_export/";
int index = homePath.lastIndexOf(packpath);
homePath = homePath.substring(0, index);
System.setProperty("test_class.home",homePath);
return homePath;
}
private static String getProjectPath(){
String homePath = getClassPath();
int index = homePath.lastIndexOf(".jar!/");
if (index != -1){
homePath = homePath.substring(0, homePath.length()-1);
index = homePath.lastIndexOf("/");
homePath = homePath.substring(0, index+1);
homePath = homePath.substring(5);
}
homePath = homePath.substring(0, homePath.length()-1);
index = homePath.lastIndexOf("/");
homePath = homePath.substring(0, index+1);
return homePath;
}
}
本文地址:http://com.8s8s.com/it/it18136.htm