Eclipse IFile.delete抛异常

0 0 java
汉有游女,不可求思。
2019-02-03 11:57:39 提问

关注 0关注

收藏 0收藏, 179浏览

大佬们,我在开发Eclipse插件中需要删除一个文件,调用获取了该文件的IFile对象,调用删除抛了异常,不能删除。请问怎么回事,下面贴出部分代码和异常。

ontains: 不能删除“E:hearken-v5.0.0
untime-Eclipse应用程序abcconfigs
ootActorsactor.xml”。
org.eclipse.core.runtime.CoreException: 删除文件时遇到了问题。
    at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:131)
    at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:304)
    at org.eclipse.core.internal.resources.ResourceTree.standardDeleteFile(ResourceTree.java:785)
    at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1979)
    at org.eclipse.core.internal.resources.Resource.delete(Resource.java:803)
    at com.sunsheen.jfids.studio.uml.ElementUtils.updateElementFile(ElementUtils.java:71)
    at com.sunsheen.jfids.studio.uml.FileTransferDropTargetListener.getCommand(FileTransferDropTargetListener.java:90)
    at org.eclipse.gef.dnd.AbstractTransferDropTargetListener.isEnabled(AbstractTransferDropTargetListener.java:403)
    at org.eclipse.jface.util.DelegatingDropAdapter.updateCurrentListener(DelegatingDropAdapter.java:377)
    at org.eclipse.jface.util.DelegatingDropAdapter.dragEnter(DelegatingDropAdapter.java:129)
    at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:61)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
    at org.eclipse.swt.dnd.DropTarget.DragEnter(DropTarget.java:297)
    at org.eclipse.swt.dnd.DropTarget.DragEnter_64(DropTarget.java:275)
    at org.eclipse.swt.dnd.DropTarget$3.method3(DropTarget.java:245)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback3(COMObject.java:92)
    at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
    at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
    at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
    at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Contains: 未能删除:E:hearken-v5.0.0
untime-Eclipse应用程序abcconfigs
ootActorsactor.xml。
    InputStream inputStream = XStreamSerializer.serializeStream(dragcommonmodel, DragCommonModel.class.getClassLoader());
        IProject currentProject = ProjectUtil.getCurrentProject();
        IFolder folder=null;
        if(type.equals("actor")){
            folder= currentProject.getFolder(Constants.PROJECT_PATH_CONFIGS_ROOT+"/Actors");
        }
        if(!folder.exists())
        folder.create(true, true, null);
        IFile file = folder.getFile("/"+dragcommonmodel.getElementFileName()+".xml");
        if(file.exists())
        file.delete(IFile.FORCE,null);
        inputStream.close();
请先 登录 后评论

0个回答

注册新账号

悬赏追问
10
  • 10
  • 20
  • 50
  • 100
  • 200
  • 输入数值
发布追问