Example usage for org.eclipse.jgit.util.io ThrowingPrintWriter ThrowingPrintWriter

List of usage examples for org.eclipse.jgit.util.io ThrowingPrintWriter ThrowingPrintWriter

Introduction

In this page you can find the example usage for org.eclipse.jgit.util.io ThrowingPrintWriter ThrowingPrintWriter.

Prototype

public ThrowingPrintWriter(Writer out) 

Source Link

Document

Construct a JGitPrintWriter

Usage

From source file:org.eclipse.emf.compare.git.pgm.internal.cmd.AbstractLogicalCommand.java

License:Open Source License

/**
 * Builds this command.//from www .  j ava 2s  .c o m
 * 
 * @param args
 *            The arguments for this command.
 * @param environmentSetupURI
 *            URI to the environment setup file.
 * @throws Die
 *             exception on error.
 * @throws IOException
 */
public void build(Collection<String> args, URI environmentSetupURI) throws Die, IOException {

    repo = parseArgumentsAndBuildRepo(args);

    try {
        final String outputEncoding;
        if (repo != null) {
            outputEncoding = repo.getConfig().getString("i18n", null, "logOutputEncoding"); //$NON-NLS-1$ //$NON-NLS-2$
        } else {
            outputEncoding = null;
        }
        BufferedWriter outbufw;
        if (outputEncoding != null) {
            outbufw = new BufferedWriter(new OutputStreamWriter(System.out, outputEncoding));
        } else {
            outbufw = new BufferedWriter(new OutputStreamWriter(System.out));
        }
        out = new ThrowingPrintWriter(outbufw);
    } catch (IOException e) {
        throw new DiesOn(SOFTWARE_ERROR).displaying("Cannot create input stream").ready();
    }

    if (!help) {
        try {
            // Loads eclipse environment setup model.
            performer = createSetupTaskPerformer(setupFile.getAbsolutePath(), environmentSetupURI);
            performer.perform();

            if (!performer.hasSuccessfullyPerformed()) {
                throw new DiesOn(DeathType.FATAL).displaying("Error durring Oomph operation").ready();
            }
        } catch (Die e) {
            throw e;
        } catch (Exception e) {
            throw new DiesOn(DeathType.FATAL).duedTo(e).ready();
        }
    }

}