Eclipse plugin 在导出的eclipse rcp产品中写入文件
我是一个新手,我正在开发eclipse rcp,并试图用保存在xml文件中的数据构建一个通讯簿。当我运行项目时,它能够读取和写入xml文件,但当我将其导出到rcp产品时,它只能读取文件,而不能写入 我试着在谷歌上搜索,但找不到相关的答案,所以我转向了谷歌 有什么建议吗 编辑这是我尝试读取文件并将其写入xml文件的方法Eclipse plugin 在导出的eclipse rcp产品中写入文件,eclipse-plugin,eclipse-rcp,Eclipse Plugin,Eclipse Rcp,我是一个新手,我正在开发eclipse rcp,并试图用保存在xml文件中的数据构建一个通讯簿。当我运行项目时,它能够读取和写入xml文件,但当我将其导出到rcp产品时,它只能读取文件,而不能写入 我试着在谷歌上搜索,但找不到相关的答案,所以我转向了谷歌 有什么建议吗 编辑这是我尝试读取文件并将其写入xml文件的方法 public void writedata() { try { DocumentBuilderFactory builderFactory = Docume
public void writedata() {
try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
URL fileURL = bundle.getEntry("/xmlfiles/person.xml");
InputStream inputStream=fileURL.openStream();
Document xmlDocument = builder.parse(inputStream);
..................................................
..................................................
..................................................
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(xmlDocument);
Bundle bundle1 = Platform.getBundle(Activator.PLUGIN_ID);
URL fileURL1 = bundle1.getEntry("/xmlfiles/person.xml");
StreamResult result = new StreamResult(new File(FileLocator.resolve(fileURL1).getPath()));
transformer.transform(source, result);
当您从Eclipse运行应用程序时,它会为您的插件使用扩展的项目文件夹。您的XML文件在此位置可写 当您导出为RCP应用程序时,您的插件将打包为插件jar文件,其中包含XML文件。您将无法写入此文件
要使文件可写,它需要位于插件项目之外,可以在RCP应用程序工作区中,也可以在外部文件夹中。谢谢nick..它可以工作..我将文件保存在我的eclipse产品文件夹中