Java File Save saveBytesAsIfile(final IFile file, final byte[] bytes)

Here you can find the source of saveBytesAsIfile(final IFile file, final byte[] bytes)

Description

Helper to write an ifile to the workspace from a string.

License

Open Source License

Parameter

Parameter Description
file The ifile object to write to
bytes The contents to write

Exception

Parameter Description
CoreException A

Declaration

public static void saveBytesAsIfile(final IFile file, final byte[] bytes) throws CoreException 

Method Source Code


//package com.java2s;
import java.io.ByteArrayInputStream;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;

public class Main {
    /**//w  w w . j  a va  2  s  . com
     * Helper to write an ifile to the workspace from a string.
     * 
     * @param file The ifile object to write to
     * @param bytes The contents to write
     * @throws CoreException A
     */
    public static void saveBytesAsIfile(final IFile file, final byte[] bytes) throws CoreException {
        file.setContents(new ByteArrayInputStream(bytes), /* force if not in sync */ true, /* keep history */ false,
                /* progress monitor */ null);
    }
}

Related

  1. save(InputStream is, OutputStream os)
  2. save(OutputStream out, InputStream iStream)
  3. saveContent(OutputStream os, byte[] content)
  4. saveConvert(String theString, boolean escapeSpace)
  5. saveDoubleMatrix(double[][] matrix, PrintStream out)
  6. saveFile(InputStream st, File testFile)