Source:
private static void importTrace(final IFolder folder, final Path path, final String targetName) { final File source = new File(path.toString()); if (source.isDirectory()) { IPath containerPath = folder.getFullPath().addTrailingSeparator().append(targetName); IOverwriteQuery overwriteImplementor = pathString -> IOverwriteQuery.NO_ALL; List<File> filesToImport = Arrays.asList(source.listFiles()); ImportOperation operation = new ImportOperation( containerPath, source, FileSystemStructureProvider.INSTANCE, overwriteImplementor, filesToImport); operation.setCreateContainerStructure(false); try { operation.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { final Exception e1 = e; TraceUtils.displayErrorMsg("Error", e1.getMessage(), e1); } catch (InterruptedException e) { final Exception e1 = e; TraceUtils.displayErrorMsg("Error", e1.getMessage(), e1); } } else { IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try (InputStream inputStream = new FileInputStream(source);) { IFile targetFile = folder.getFile(targetName); targetFile.create(inputStream, IResource.NONE, monitor); } catch (CoreException | IOException e) { TraceUtils.displayErrorMsg("Error", e.getMessage(), e); Activator.getDefault().logError(e.getMessage(), e); } } }; WorkspaceModifyDelegatingOperation operation = new WorkspaceModifyDelegatingOperation(runnable); try { operation.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { final Exception e1 = e; TraceUtils.displayErrorMsg("Error", e1.getMessage(), e1); Activator.getDefault().logError(e.getMessage(), e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }

Target:
private static void importTrace(final IFolder folder, final Path path, final String targetName) { final File source = new File(path.toString()); if (source.isDirectory()) { IPath containerPath = folder.getFullPath().addTrailingSeparator().append(targetName); IOverwriteQuery overwriteImplementor = pathString -> IOverwriteQuery.NO_ALL; List<File> filesToImport = Arrays.asList(source.listFiles()); ImportOperation operation = new ImportOperation( containerPath, source, FileSystemStructureProvider.INSTANCE, overwriteImplementor, filesToImport); operation.setCreateContainerStructure(false); try { operation.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { TraceUtils.displayErrorMsg(e.getClass().getSimpleName(), e.getMessage(), e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } else { IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try (InputStream inputStream = new FileInputStream(source);) { IFile targetFile = folder.getFile(targetName); targetFile.create(inputStream, IResource.NONE, monitor); } catch (CoreException | IOException e) { TraceUtils.displayErrorMsg(e.getClass().getSimpleName(), e.getMessage(), e); } } }; WorkspaceModifyDelegatingOperation operation = new WorkspaceModifyDelegatingOperation(runnable); try { operation.run(new NullProgressMonitor()); } catch (InvocationTargetException e) { TraceUtils.displayErrorMsg(e.getClass().getSimpleName(), e.getMessage(), e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }