Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IFile.create()


            public void execute(final IProgressMonitor monitor)
                    throws CoreException {
                try {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    writeModel(out);
                    file.create(new ByteArrayInputStream(out.toByteArray()),
                            true, monitor);
                    out.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
View Full Code Here


                WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
                    public void execute(final IProgressMonitor monitor)
                            throws CoreException {
                        try {
                            ByteArrayOutputStream out = new ByteArrayOutputStream();
                            newFile.create(new ByteArrayInputStream(output.getBytes()), true, monitor);
                            out.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
View Full Code Here

     * @return
     * @throws CoreException
     */
    public IFile createFile(IContainer folder, String filename, String fileContent) throws CoreException {
        IFile createdFile = folder.getFile(new Path(filename));
        createdFile.create(new ByteArrayInputStream(fileContent.getBytes()), true, null);
        return createdFile;
    }

    /**
     * @param folderName
View Full Code Here

        String filename = constructTemplateFilename(unit);
        String content = Preferences.getTemplateMarkup();
        try {
            fileToCreate = packageFolder.getFile(filename);
            if (!fileToCreate.exists()) {
                fileToCreate.create(new ByteArrayInputStream(content.getBytes()), true, null);
            }
        }
        catch (CoreException e) {
            e.printStackTrace();
        }
View Full Code Here

    IFile buildFile = targetFolder.getFile("build.xml");
    ByteArrayInputStream source = new ByteArrayInputStream(script.getBytes());
    if (buildFile.exists()) {
      buildFile.setContents(source, true, true, null);
    } else {
      buildFile.create(source, true, null);
    }
  }

  private String getScriptTemplate() throws Exception {
    IProject project = m_selectedModule.getProject();
View Full Code Here

    public void setActivePart(IAction action, IWorkbenchPart targetPart) {}

    private static void ensureBndBndExists(IProject project) throws CoreException {
        IFile bndfile = project.getFile(Project.BNDFILE);
        if (!bndfile.exists())
            bndfile.create(new ByteArrayInputStream(new byte[0]), false, null);
    }

    /**
     * Toggles sample nature on a project
     *
 
View Full Code Here

        SubMonitor progress = SubMonitor.convert(monitor, encoding != null ? 2 : 1);

        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

        IFile file = root.getFile(path);
        file.create(source, updateFlags, progress.newChild(1, SubMonitor.SUPPRESS_NONE));

        if (encoding != null)
            file.setCharset(encoding, progress.newChild(1, SubMonitor.SUPPRESS_NONE));

        return new DeleteResourceChange(path, true);
View Full Code Here

        IPath destinationPath = new Path(sourcePath).makeRelativeTo(sourcePrefix);
        IFile file = destination.getFile(destinationPath);

        try {
            if (!file.exists()) {
                file.create(entry.openStream(), false, monitor);
            } else {
                file.setContents(entry.openStream(), false, true, monitor);
            }
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Failed to load data from template source bundle.", e));
View Full Code Here

    try {
      InputStream stream = openContentStream();
      if (file.exists()) {
        file.setContents(stream, true, true, null);
      } else {
        file.create(stream, true, null);
      }
      stream.close();
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here

                WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
                    public void execute(final IProgressMonitor monitor)
                            throws CoreException {
                        try {
                            ByteArrayOutputStream out = new ByteArrayOutputStream();
                            newFile.create(new ByteArrayInputStream(output.getBytes()), true, monitor);
                            out.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.