Eclipse获取路径/Eclipse/Path/get path/find path
2009-10-27 11:40
253 查看
1. 得到某PLUGIN的路径:
Platform.getBundle("mypluginid").getLocation().
eclipse采用osgi后好像还可以:
Activator.getDefault().getBundle().getLocation().(前提是这个插件有Activator这个类.这个类继承了ECLIPSE的Plugin类)
eclipse采用osgi前好像好像是:
MyPlugin.getDefault().getBundle().getLocation().(前提是这个插件有MyPlugin这个类.这个类继承了ECLIPSE的Plugin类)
2. 得到工作区路径: Platform.getlocation();或
ResourcesPlugin.getWorkspace();好像
Platform.getInstanceLocation()也可行
3. 得到ECLIPSE安装路径
Platform.getInstallLocation();
4. 从插件中获得绝对路径:
AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()
5. 通过文件得到工程Project:
IProject project = ((IFile)o).getProject();
通过文件得到全路径:
String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();
6. 获得工作空间workspace:
得到Appliaction workspace:
Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();
得到runtime workspace:
Platform.getInstanceLocation().getURL().getPath();
7. 得到整个Workspace的根:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
从根来查找资源:
IResource resource = root.findMember(new Path(containerName));
从Bundle来查找资源:
Bundle bundle = Platform.getBundle(pluginId);
URL fullPathString = BundleUtility.find(bundle, filePath);
8. 从编辑器来获得编辑文件
IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
IEditorInput input = editor.getEditorInput();
if(input instanceof IFileEditorInput){
IFile file = ((IFileEditorInput)input).getFile();
}
获取插件的绝对路径:
FileLocator.resolve(BuildUIPlugin.getDefault().getBundle().getEntry("/")).getFile();
Platform.getBundle("mypluginid").getLocation().
eclipse采用osgi后好像还可以:
Activator.getDefault().getBundle().getLocation().(前提是这个插件有Activator这个类.这个类继承了ECLIPSE的Plugin类)
eclipse采用osgi前好像好像是:
MyPlugin.getDefault().getBundle().getLocation().(前提是这个插件有MyPlugin这个类.这个类继承了ECLIPSE的Plugin类)
2. 得到工作区路径: Platform.getlocation();或
ResourcesPlugin.getWorkspace();好像
Platform.getInstanceLocation()也可行
3. 得到ECLIPSE安装路径
Platform.getInstallLocation();
4. 从插件中获得绝对路径:
AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()
5. 通过文件得到工程Project:
IProject project = ((IFile)o).getProject();
通过文件得到全路径:
String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();
6. 获得工作空间workspace:
得到Appliaction workspace:
Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();
得到runtime workspace:
Platform.getInstanceLocation().getURL().getPath();
7. 得到整个Workspace的根:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
从根来查找资源:
IResource resource = root.findMember(new Path(containerName));
从Bundle来查找资源:
Bundle bundle = Platform.getBundle(pluginId);
URL fullPathString = BundleUtility.find(bundle, filePath);
8. 从编辑器来获得编辑文件
IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
IEditorInput input = editor.getEditorInput();
if(input instanceof IFileEditorInput){
IFile file = ((IFileEditorInput)input).getFile();
}
获取插件的绝对路径:
FileLocator.resolve(BuildUIPlugin.getDefault().getBundle().getEntry("/")).getFile();
相关文章推荐
- java 之 HttpServlet 获取GET或者POST字段(getParameter) 获取配置getServletContext 和 获取某个文件绝对路径(getPath)
- 从request获取各种路径总结 request.getRealPath("url"); // 虚拟目录映射为实际目录 request.getRealPat
- 【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别
- 获取指定的系统路径 SHGetSpecialFolderPath
- 利用getClassLoader().getResource(*).getPath()获取绝对路径时,因为空格不能获取绝对路径的问题
- 文件路径的获取《file的getPath getAbsolutePath和getCanonicalPath的不同》
- servlet之getRealPath获取路径问题。
- idea和eclipse中getAbsolutePath()方法获取值不同
- 从request获取各种路径总结 request.getRealPath("url"); // 虚拟目录映射为实际目录 request.getRealPat
- Windows API——SHGetSpecialFolderPath——获取系统特殊路径
- 【JAVA】关于java中 类.class.getResource("/").getPath()获取路径有空格的问题
- 有关Linux下request.getRealPath("/")获取路径的问题
- JavaSE8基础 File getAbsolutePath 获取当前默认的工作文件夹路径
- java中file类的三种获取路径的方法getPath(),getAbsolutePath(),getCanonicalPath()的比较
- ###request获取请求路径内容的相关方法总结。例如:request.getContextPath()。。。
- Windows API——SHGetSpecialFolderPath——获取系统特殊路径
- 从request获取各种路径总结 request.getRealPath("url"); // 虚拟目录映射为实际目录 request.getRealPat
- String path = request.getContextPath();获取应用的上下文路径。
- ServletActionContext.getServletContext().getRealPath("/upload");myeclipseyeclipse获取路径不一样的原因
- SHGetSpecialFolderPath获取系统路径