eclipse中获得插件绝对路径的方法

eclipse中获得插件绝对路径的方法
获得插件的绝对路径:
     /** */ /**
     * 得到插件的绝对路径
     * 
     * 
@return 路径
     
*/

    
public   static  String getPath()  {
        String path;
        
try {
            path 
= FileLocator.toFileURL(
                    Platform.getBundle(pluginId).getEntry(
"")).getPath();
            path 
= path.substring(path.indexOf("/"+ 1, path.length());
        }
 catch (IOException e) {
            path 
= "";
            e.printStackTrace();
        }

        
return path;
    }
其中FileLocator#toFileURL是在3.2中添加的,代替了原来的Platform#asLocalURL,并且对于FileLocator#toFileURL,if the plugin was a jar, it will extract the file into a temporary location

你可能感兴趣的:(eclipse中获得插件绝对路径的方法)