Example usage for org.eclipse.jgit.util FS exists

List of usage examples for org.eclipse.jgit.util FS exists

Introduction

In this page you can find the example usage for org.eclipse.jgit.util FS exists.

Prototype

public boolean exists(File path) 

Source Link

Document

Tests if the path exists, in case of a symbolic link, true even if the target does not exist

Usage

From source file:com.itemis.maven.plugins.unleash.scm.providers.merge.UnleashGitMerger.java

License:Eclipse Distribution License

/**
 * Writes merged file content to the working tree.
 *
 * @param result//from  w  w w .  j a  va2  s.com
 *          the result of the content merge
 * @return the working tree file to which the merged content was written.
 * @throws FileNotFoundException
 * @throws IOException
 */
private File writeMergedFile(MergeResult<RawText> result) throws FileNotFoundException, IOException {
    File workTree = this.db.getWorkTree();
    FS fs = this.db.getFS();
    File of = new File(workTree, this.tw.getPathString());
    File parentFolder = of.getParentFile();
    if (!fs.exists(parentFolder)) {
        parentFolder.mkdirs();
    }
    OutputStream os = null;
    try {
        os = new BufferedOutputStream(new FileOutputStream(of));
        new MergeFormatter().formatMerge(os, result, Arrays.asList(this.commitNames), CHARACTER_ENCODING);
    } finally {
        Closeables.close(os, true);
    }
    return of;
}