Example usage for java.nio.file Paths get

List of usage examples for java.nio.file Paths get

Introduction

In this page you can find the example usage for java.nio.file Paths get.

Prototype

public static Path get(URI uri) 

Source Link

Document

Converts the given URI to a Path object.

Usage

From source file:bit.changepurse.wdk.bip.TestBip39EN.java

public static String readTestVectors() {
    URL resource = TestBip39EN.class.getResource(TEST_VECTORS);
    Path path = Paths.get(newURI(resource));
    return readTextFile(path);
}

From source file:TestUtils.java

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

From source file:io.spikex.core.integration.MainTest.java

@BeforeClass
public static void init() throws IOException {
    Path nodeRepoPath1 = Paths.get("build/resources/test/node1/repo");
    Path nodeRepoPath2 = Paths.get("build/resources/test/node2/repo");
    Files.createDirectories(nodeRepoPath1);
    Files.createDirectories(nodeRepoPath2);

    // Copy repo to node home directories
    // The repos are defined in repos.txt that is found on the classpath
    Path repoPath = Paths.get("build/resources/test/repo");
    FileUtils.copyDirectory(repoPath.toFile(), nodeRepoPath1.toFile());
    FileUtils.copyDirectory(repoPath.toFile(), nodeRepoPath2.toFile());

    //        System.out.println(ClassLoader.getSystemClassLoader().getResource(".").getPath());
}

From source file:io.onedecision.engine.decisions.test.MockMultipartFileUtil.java

public static MultipartFile newInstance(String dmnResource) {
    File baseDir = new File("target" + File.separator + "test-classes");
    File dmnToUpload = new File(baseDir, dmnResource);
    assertTrue("Cannot find DMN file to use as test input", dmnToUpload.exists());

    Path path = Paths.get(dmnToUpload.getAbsolutePath());
    String name = "file.dmn";
    String originalFileName = "file.dmn";
    String contentType = "application/xml";
    byte[] content = null;
    try {/*from  w w w . j  av a2  s  .co  m*/
        content = Files.readAllBytes(path);
    } catch (final IOException e) {
    }
    MultipartFile mpf = new MockMultipartFile(name, originalFileName, contentType, content);
    return mpf;
}

From source file:file.FileOperatorTest.java

/**
 *http://stackoverflow.com/questions/16524065/is-filevisitoption-follow-links-the-only-filevisitoption-available
 *///from  ww  w. j  ava  2s  .c  o  m
public static List<Path> testWalkFileWithStream() {
    try {
        System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "20");
        long a = System.currentTimeMillis();
        Files.walk(Paths.get(ROOT_DIR), FileVisitOption.FOLLOW_LINKS).parallel().filter(x -> {
            return x.toFile().isFile();
        }).forEach(x -> {
            // Files.copy(x, Paths.get(""), CopyOption )
        });
        long b = System.currentTimeMillis();
        System.out.println(":" + (b - a));
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.kixeye.chassis.bootstrap.TestUtils.java

public static OutputStream createFile(String path) {
    try {/*from   ww  w .java2s . co  m*/
        Path p = Paths.get(SystemPropertyUtils.resolvePlaceholders(path));
        if (Files.exists(p)) {
            Files.delete(p);
        }
        File file = new File(path);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                throw new RuntimeException("Unable to create parent file(s) " + file.getParent());
            }
        }
        return Files.newOutputStream(p);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.notes.listen.FsWatchService.java

public static void start(String path) {
    if (fsw == null) {
        lock.lock();//from w  w w.j  a  va  2s  .c  o m
        if (fsw == null) {
            try {
                fsw = new FsWatcher(EventInst.getInstance().getAsyncEventBus(), Paths.get(path));
                try {
                    fsw.start();

                } catch (IOException ex) {
                    Logger.getLogger(FsWatchService.class.getName()).log(Level.SEVERE, null, ex);
                }
            } finally {
                lock.unlock();
            }
        }
    }
}

From source file:org.n52.oss.util.Util.java

public static String readResourceFile(String s) {
    URL resource = Util.class.getResource(s);
    Path path;//from   w w w.  java 2  s.c  o m
    try {
        path = Paths.get(resource.toURI());
    } catch (URISyntaxException e) {
        log.error("Could not read from resource path " + s, e);
        return "";
    }
    return readResourceFile(path);
}

From source file:demo.utils.MiniClusterUtils.java

public static void startMiniCluster() {
    if (clusterLauncher != null) {
        throw new IllegalStateException("MiniClustrer is currently running");
    }/*from w  ww  .  j  a  v a  2s. c  om*/
    File file = new File(System.getProperty("user.dir"));
    Path path = Paths.get(file.getAbsolutePath());
    Path parentPath = path.getParent();
    String[] resources = file.list();
    for (String resource : resources) {
        if (resource.equals("yaya-demo")) {
            parentPath = path;
            break;
        }
    }
    File miniClusterExe = new File(
            parentPath.toString() + "/yarn-test-cluster/build/install/yarn-test-cluster/bin/yarn-test-cluster");
    System.out.println(miniClusterExe.getAbsolutePath());
    if (!miniClusterExe.exists()) {
        logger.info("BUILDING MINI_CLUSTER");
        CommandProcessLauncher buildLauncher = new CommandProcessLauncher(
                path.toString() + "/build-mini-cluster");
        buildLauncher.launch();
    }
    Assert.isTrue(miniClusterExe.exists(), "Failed to find mini-cluster executable");
    clusterLauncher = new CommandProcessLauncher(miniClusterExe.getAbsolutePath());
    executor = Executors.newSingleThreadExecutor();
    executor.execute(new Runnable() {
        @Override
        public void run() {
            logger.info("STARTING MINI_CLUSTER");
            clusterLauncher.launch();
        }
    });
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
}

From source file:io.github.lxgaming.mcc.Configuration.java

public static void loadConfig() {
    LogManager.info("Loading Configuration File...");
    if (!CONFIGFILE.exists()) {
        saveConfig("Creating");
    }//w w w .  j a  va  2 s  .co m

    try {
        CONFIG = new JSONObject(new String(Files.readAllBytes(Paths.get(CONFIGFILE.getPath())), "UTF-8"));
        EMAIL = CONFIG.getString("Email");
        CLIENTTOKEN = CONFIG.getString("ClientToken");
        ACCESSTOKEN = CONFIG.getString("AccessToken");
        CONNECTMESSAGE = CONFIG.getString("ConnectMessage");
        COMMANDPREFIX = CONFIG.getString("CommandPrefix");
        FONTNAME = CONFIG.getString("FontName");
        FONTSIZE = CONFIG.getString("FontSize");
        THEME = CONFIG.getString("Theme");
        LogManager.info("Configuration File Successfully Loaded");
    } catch (Exception ex) {
        LogManager.error("Configuration File Failed to Load");
    }
    return;
}