Here you can find the source of copyFileToContainer(File pChild, IContainer pContainer)
private static void copyFileToContainer(File pChild, IContainer pContainer) throws Exception
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; public class Main { private static void copyFileToContainer(File pChild, IContainer pContainer) throws Exception { if (pChild.isDirectory()) { internalCopyFolderToContainer(pChild, pContainer); } else {// w ww.j a va 2 s . c o m internalCopyFileToContainer(pChild, pContainer); } } private static void internalCopyFolderToContainer(File pChild, IContainer pContainer) throws CoreException, Exception { IFolder folder = pContainer.getFolder(new Path(pChild.getName())); folder.create(true, true, null); for (File child : pChild.listFiles()) { copyFileToContainer(child, folder); } } private static void internalCopyFileToContainer(File pChild, IContainer pContainer) throws FileNotFoundException, CoreException { InputStream in = new FileInputStream(pChild); IFile newFile = pContainer.getFile(new Path(pChild.getName())); newFile.create(in, true, null); } }