Example usage for java.nio.file Files readAllBytes

List of usage examples for java.nio.file Files readAllBytes

Introduction

In this page you can find the example usage for java.nio.file Files readAllBytes.

Prototype

public static byte[] readAllBytes(Path path) throws IOException 

Source Link

Document

Reads all the bytes from a file.

Usage

From source file:sonata.kernel.vimadaptor.wrapper.openstack.javastackclient.JavaStackUtils.java

public static String readFile(String filePath) throws IOException {
    return new String(Files.readAllBytes(Paths.get(filePath)));
}

From source file:createbulksubdomainconfig.CreateBulkSubdomainConfig.java

protected void Initialilze() {
    try {//from ww  w .ja  va  2s  .c o m
        mHtAccess = new String(Files.readAllBytes(new File("./.htaccess").toPath()));
        mConfig = new String(Files.readAllBytes(new File("./config.php").toPath()));
        mDatabase = new String(Files.readAllBytes(new File("./database.php").toPath()));
        CreateFolders mFolders = new CreateFolders();
        mFolders.start("./bloodbanks_installation.xls");
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.zalando.stups.swagger.codegen.YamlToJsonTest.java

protected static String getResourceContent(final String classpathResource) {
    try {//w w w  . ja  v  a2 s . c  om
        return new String(Files.readAllBytes(
                java.nio.file.Paths.get(YamlToJsonTest.class.getResource(classpathResource).toURI())));
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.meplato.store2.MockResponse.java

/**
 * Parse a response from a Path object.//from  w  w  w.ja  va  2  s  .c o  m
 *
 * @param path
 * @return Response
 * @throws IOException
 * @throws HttpException
 * @throws ServiceException
 */
public static Response fromPath(Path path) throws IOException, HttpException, ServiceException {
    String contents = new String(Files.readAllBytes(path));
    return fromContents(contents);
}

From source file:com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfigurationTest.java

@Test
public void testParseYaml() throws Exception {
    String source = new String(
            Files.readAllBytes(Paths
                    .get(System.getProperty("user.dir") + "\\src\\test\\resources\\apimanagement\\api.yaml")),
            Charset.defaultCharset());

    ApiManagementConfiguration conf = new ApiManagementConfiguration();
    conf.setLocation(source);/*from   w w w  .  j av  a 2 s .  c  o  m*/
    Map<String, Policy> policies = conf.getPolicies();
    for (Policy p : policies.values()) {
        System.out.println(p);
    }
    Map<String, Key> keys = conf.getKeys();
    for (Key k : keys.values()) {
        System.out.println(k);
    }

}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static String fileContentToString(String filepath) throws IOException {
    Path p = Paths.get(filepath);
    byte[] contents = Files.readAllBytes(p);
    return new String(contents, StandardCharsets.UTF_8);
}

From source file:com.olacabs.fabric.executor.impl.FileMetadataSource.java

@Override
public ComputationSpec load(String path) throws Exception {
    return objectMapper.readValue(Files.readAllBytes(Paths.get(path)), ComputationSpec.class);
}

From source file:com.klarna.hiverunner.builder.HiveResource.java

HiveResource(String targetFile, Path dataFile) throws IOException {
    this(targetFile, createOutputStream(Files.readAllBytes(dataFile)));
}

From source file:mpimp.assemblxweb.util.J5FileUtils.java

public static String encodeFileBase64(String filePath) throws Exception {
    Path path = Paths.get(filePath);
    String result = "";
    try {//from  w  ww .  j  a va 2 s. c o  m
        byte[] content = Files.readAllBytes(path);
        result = Base64.encodeBase64String(content);
    } catch (IOException e) {
        String message = "Error while encoding file " + filePath + ". " + e.getMessage();
        throw new AssemblXException(message, J5FileUtils.class);
    }
    return result;
}

From source file:io.pivotal.ecosystem.servicebroker.service.CatalogService.java

private static String getContents(String fileName) throws IOException {
    URI u = new ClassPathResource(fileName).getURI();
    return new String(Files.readAllBytes(Paths.get(u)));
}