Here you can find the source of copyBundleFile(IPath projectRelativePath, String outputPath)
public static void copyBundleFile(IPath projectRelativePath, String outputPath) throws CoreException
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.osgi.framework.Bundle; import ch.hsr.ifs.sconsolidator.core.SConsPlugin; public class Main{ public static void copyBundleFile(IPath projectRelativePath, String outputPath) throws CoreException { InputStream is = null;/*from w w w . j av a 2s .co m*/ FileOutputStream to = null; try { is = FileLocator.openStream(getBundle(), projectRelativePath, false); to = new FileOutputStream(outputPath); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { to.write(buffer, 0, bytesRead); } } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SConsPlugin.PLUGIN_ID, e.getMessage())); } finally { IOUtil.safeClose(is); IOUtil.safeClose(to); } } private static Bundle getBundle() { return SConsPlugin.getDefault().getBundle(); } }