Example usage for io.vertx.core.file FileSystem readFileBlocking

List of usage examples for io.vertx.core.file FileSystem readFileBlocking

Introduction

In this page you can find the example usage for io.vertx.core.file FileSystem readFileBlocking.

Prototype

Buffer readFileBlocking(String path);

Source Link

Document

Blocking version of #readFile(String,Handler)

Usage

From source file:de.braintags.netrelay.init.Settings.java

License:Open Source License

private static Settings loadSettings(NetRelay netRelay, Vertx vertx, String path) {
    FileSystem fs = vertx.fileSystem();
    if (fs.existsBlocking(path)) {
        LOGGER.info("going to load settings from " + path);
        Buffer buffer = fs.readFileBlocking(path);
        Settings settings = Json.decodeValue(buffer.toString(), Settings.class);
        LOGGER.info("settings successfully loaded from " + path);
        return settings;
    } else {/*from   ww  w. j  a v  a  2s. c om*/
        LOGGER.info("creating default settings and store them in " + path);
        Settings settings = netRelay.createDefaultSettings();
        fs.writeFileBlocking(path, Buffer.buffer(Json.encodePrettily(settings)));
        String message = String.format(
                "Settings file did not exist and was created new in path %s. NOTE: edit the file, set edited to true and restart the server",
                path);
        throw new InitException(message);
    }

}

From source file:io.flowly.engine.compilers.CompileInlineScript.java

License:Open Source License

private static void loadScript(StringBuilder output, String scriptId, FileSystem fileSystem,
        String appFolderPath) {//from w  w w  .  ja  v  a2  s .  c o m
    // Empty script.
    if (scriptId == null || scriptId.length() == 0) {
        return;
    }

    output.append(Compiler.LINE_BREAK);
    output.append("    /* ############### Begin inline script: ").append(scriptId)
            .append(" ############### */");
    output.append(Compiler.LINE_BREAK);

    String scriptPath = PathUtils.createPath(appFolderPath, PathUtils.SCRIPTS_FOLDER,
            scriptId + PathUtils.DOT_JS_SUFFIX);
    output.append(new String(fileSystem.readFileBlocking(scriptPath).getBytes()));

    output.append(Compiler.LINE_BREAK);
    output.append("    /* ############### End inline script ############### */");
    output.append(Compiler.LINE_BREAK);
    output.append(Compiler.LINE_BREAK);
}