今天在開發Eclipse插件時用到了Eclipse 文件資源,不知道在調試插件過程中如何調用自定義的圖片,于是在網上查了許久,有如下說明:對路徑的測試代碼:????System.out.println(?Thread.currentThread().getContextClassLoader().getResource(""));????System.out.println(PathTest.class.getClassLoader().getResource(""));????System.out.println(ClassLoader.getSystemResource(""));????System.out.println(PathTest.class.getResource(""));????System.out.println(PathTest.class.getResource("/"));????System.out.println(new?File("").getAbsolutePath());????System.out.println(System.getProperty("user.dir"));結果如下:???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/com/wxxr/boss/config/???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/???E:\wxxr_projects2\wxxr-applications\wxxr-boss-connector???E:\wxxr_projects2\wxxr-applications\wxxr-boss-connector一般情況是使用ClassLoader.getSystemResource("");但是在調試插件時其返回結果為NULL,郁悶不已,于是又看到如下文章:從插件中獲得絕對路徑:???????
通過文件得到Project:
通過文件得到全路徑:
得到整個Workspace的根:
從根來查找資源:
從Bundle來查找資源:
得到Appliaction workspace:
得到runtimeworkspace:?
從編輯器來獲得編輯文件
Copyright @ 哼哼 Powered by: .Text and ASP.NET Theme by: .NET Monster