Example usage for java.nio.file Path toFile

List of usage examples for java.nio.file Path toFile

Introduction

In this page you can find the example usage for java.nio.file Path toFile.

Prototype

default File toFile() 

Source Link

Document

Returns a File object representing this path.

Usage

From source file:tpt.dbweb.cat.evaluation.ComparisonResult.java

public static ComparisonResult read(Path file) throws JsonParseException, JsonMappingException, IOException {
    return mapper.readValue(file.toFile(), ComparisonResult.class);
}

From source file:Main.java

private static Path unzip(Path tmpDir, Path zipPath, String name) throws IOException {
    Path outPath = tmpDir.resolve(zipPath.getFileName());
    try (ZipFile zipFile = new ZipFile(zipPath.toFile())) {
        Files.copy(zipFile.getInputStream(zipFile.getEntry(name)), outPath,
                StandardCopyOption.REPLACE_EXISTING);
        return outPath;
    }//from  w w w  .j  a va  2s. c  o m
}

From source file:com.thesmartguild.firmloader.lib.tftp.TFTPServerFactory.java

private static Path createTempDirectory() throws IOException {
    Path tmpFilePath = Files.createTempDirectory("TheSmartGuild_TFTPServer");
    tmpFilePath.toFile().deleteOnExit();
    return tmpFilePath;
}

From source file:com.heliosdecompiler.helios.utils.APKTool.java

public static void decodeResources(File input, File output) {
    try {//from   w  w w  .j a v a2 s  .  c  o  m
        Path temporaryDirectory = Files.createTempDirectory("apkresources");
        File directory = temporaryDirectory.toFile();
        Files.delete(temporaryDirectory);
        cmdDecode(input, directory);
        File original = new File(directory, "original");
        FileUtils.deleteDirectory(original);
        File apktool = new File(directory, "apktool.yml");
        apktool.delete();
        ZipUtil.pack(directory, output);
        FileUtils.deleteDirectory(directory);
    } catch (Exception e) {
        ExceptionHandler.handle(e);
    }
}

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:com.rom.jmultipatcher.Utils.java

public static void checkFilePermissions(final String filepath, final boolean canRead, final boolean canWrite) {
    final Path path = Paths.get(filepath);
    final File file = path.toFile();
    if (canRead && !file.canRead()) {
        throw new IllegalArgumentException("Can't read file" + filepath);
    }//from  w  ww.  j a  v  a 2 s . c o  m
    if (canWrite && !file.canWrite()) {
        throw new IllegalArgumentException("Can't write to file" + filepath);
    }
}

From source file:ch.elexis.importer.div.Helpers.java

static void removeTempDirectory(Path path) {
    try {/*from   w  w w.j ava2s  .  c o  m*/
        FileUtils.deleteDirectory(path.toFile());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:fr.cnrs.sharp.reasoning.Harmonization.java

public static File harmonizeProv(File inputProv) throws IOException {
    Model inputGraph = FileManager.get().loadModel(inputProv.getAbsolutePath());
    Model harmonizedProv = harmonizeProv(inputGraph);

    Path pathInfProv = Files.createTempFile("PROV-inf-tgd-egd-", ".ttl");
    harmonizedProv.write(new FileWriter(pathInfProv.toFile()), "TTL");
    logger.info("PROV inferences file written to " + pathInfProv.toString());
    return pathInfProv.toFile();
}

From source file:com.fizzed.blaze.kotlin.BlazeKotlinEngineTest.java

@BeforeClass
static public void clearCache() throws IOException {
    Context context = new ContextImpl(null, Paths.get(System.getProperty("user.home")), null, null);
    Path classesDir = ConfigHelper.userBlazeEngineDir(context, "kotlin");
    FileUtils.deleteDirectory(classesDir.toFile());
}

From source file:org.cyclop.test.AbstractTestCase.java

private static void rmdir(Path dir) throws IOException {
    File dirFile = dir.toFile();
    if (dirFile.exists()) {
        FileUtils.deleteRecursive(dirFile);
    }//  w w w.  jav  a 2  s.  c  o m
}