Example usage for java.nio.channels FileChannel open

List of usage examples for java.nio.channels FileChannel open

Introduction

In this page you can find the example usage for java.nio.channels FileChannel open.

Prototype

public static FileChannel open(Path path, OpenOption... options) throws IOException 

Source Link

Document

Opens or creates a file, returning a file channel to access the file.

Usage

From source file:org.polago.deployconf.DeployConfRunner.java

/**
 * Gets a DeploymentConfig instance from a Path.
 *
 * @param path the file to use//from   w w w  .j  a v  a 2 s.c  om
 * @return a DeploymentConfig representation of the ReadableByteChannel
 * @throws Exception indicating error
 */
private DeploymentConfig getDeploymentConfigFromPath(Path path) throws Exception {

    ReadableByteChannel ch = FileChannel.open(path, StandardOpenOption.READ);
    InputStream is = Channels.newInputStream(ch);

    DeploymentReader reader = new DeploymentReader(is, getGroupManager());
    DeploymentConfig result = reader.parse();
    ch.close();

    return result;
}