当前位置: 首页>>代码示例>>Java>>正文


Java Files.createDirectories方法代码示例

本文整理汇总了Java中java.nio.file.Files.createDirectories方法的典型用法代码示例。如果您正苦于以下问题:Java Files.createDirectories方法的具体用法?Java Files.createDirectories怎么用?Java Files.createDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.Files的用法示例。


在下文中一共展示了Files.createDirectories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyJavaBase

import java.nio.file.Files; //导入方法依赖的package包/类
private void copyJavaBase(Path targetDir) throws IOException {
    FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
    Path javaBase = jrt.getPath("modules", "java.base");

    if (!Files.exists(javaBase)) {
        throw new AssertionError("No java.base?");
    }

    Path javaBaseClasses = targetDir.resolve("java.base");

    for (Path clazz : tb.findFiles("class", javaBase)) {
        Path target = javaBaseClasses.resolve(javaBase.relativize(clazz).toString());
        Files.createDirectories(target.getParent());
        Files.copy(clazz, target);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:IncubatingTest.java

示例2: DefaultIRIConverterPortuguese

import java.nio.file.Files; //导入方法依赖的package包/类
public DefaultIRIConverterPortuguese(QueryExecutionFactory qef, String cacheDirectory) {
	this.qef = qef;

	// use tmp as default cache directory
	if (cacheDirectory == null) {
		cacheDirectory = System.getProperty("java.io.tmpdir") + "/triple2nl/cache/portuguese";
	}

	cacheDirectory += "/dereferenced";
	try {
		Files.createDirectories(Paths.get(cacheDirectory));
	} catch (IOException e) {
		logger.error("Creation of folder + " + cacheDirectory + " failed.", e);
	}
	logger.debug("Using folder " + cacheDirectory + " as cache for IRI converter.");

	uriDereferencer = new URIDereferencer(new File(cacheDirectory));
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:19,代码来源:DefaultIRIConverterPortuguese.java

示例3: copyFile

import java.nio.file.Files; //导入方法依赖的package包/类
private static void copyFile(File f) {
    try {
        Path classFilePath = Paths.get(classFile);
        String packagePath = classFilePath.getParent() == null ? "" : classFilePath.getParent().toString();
        Path p = Paths.get(destinationDir + packagePath + File.separator + f.getName());
        Files.createDirectories(p.getParent());
        try (InputStream is = new FileInputStream(f)) {
            Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
        }

        if (removeSource && !f.delete()) {
            throw new RuntimeException("Failed to delete a file");
        }

    } catch (IOException ex) {
        throw new RuntimeException("Could not copy file " + f, ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:CopyClassFile.java

示例4: ResultWriter

import java.nio.file.Files; //导入方法依赖的package包/类
public ResultWriter(ItemsetMinerConfiguration<LabelType> itemsetMinerConfiguration, ItemsetMiner<LabelType> itemsetMiner) throws IOException {
    this.itemsetMinerConfiguration = itemsetMinerConfiguration;
    outputPath = Paths.get(itemsetMinerConfiguration.getOutputLocation());

    if (outputPath.toFile().exists()) {
        long outputFolderCount = Files.list(outputPath.getParent())
                                      .filter(path -> path.getFileName().toString().startsWith(outputPath.getFileName().toString()))
                                      .count();
        Path movedPath = outputPath.getParent().resolve(outputPath.getFileName() + "." + outputFolderCount);
        logger.info("output folder already present, will be renamed to {}", movedPath);
        Files.move(outputPath, movedPath);
    }

    logger.debug("creating path {}", outputPath);
    Files.createDirectories(outputPath);
    this.itemsetMiner = itemsetMiner;
    logger.info("results will be written to {}", itemsetMinerConfiguration.getOutputLocation());
}
 
开发者ID:enauz,项目名称:mmm,代码行数:19,代码来源:ResultWriter.java

示例5: testPackageNoModule

import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void testPackageNoModule(Path base) throws Exception {
    Path src = base.resolve("src");
    Path classes = base.resolve("classes");

    Files.createDirectories(classes);

    tb.writeJavaFiles(src,
                      "package api; public class Api { }");

    String log = new JavacTask(tb)
            .options("-processor", VerifyPackageNoModule.class.getName(),
                     "-source", "8",
                     "-Xlint:-options")
            .outdir(classes)
            .files(findJavaFiles(src))
            .run()
            .writeAll()
            .getOutput(Task.OutputKind.DIRECT);

    if (!log.isEmpty())
        throw new AssertionError("Unexpected output: " + log);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:AnnotationProcessing.java

示例6: onExecuteCommand

import java.nio.file.Files; //导入方法依赖的package包/类
@Override
public void onExecuteCommand(CommandSender sender, String[] args)
{
    try{

        FileUtils.deleteDirectory(new File("local/cache"));
        Files.createDirectories(Paths.get("local/cache/web_templates"));
        Files.createDirectories(Paths.get("local/cache/web_plugins"));

    }catch (Exception ex){
        ex.printStackTrace();
    }

    sender.sendMessage("The Cache was cleared!");
}
 
开发者ID:Dytanic,项目名称:CloudNet,代码行数:16,代码来源:CommandClearCache.java

示例7: load

import java.nio.file.Files; //导入方法依赖的package包/类
public static HoconConfigFile load(@Nonnull final Path path,
                                   @Nonnull final String resource,
                                   final boolean overwrite) throws IOException {
    if (overwrite) {
        Files.deleteIfExists(path);
    }

    if (!Files.exists(path)) {
        Files.createDirectories(path.getParent());

        if (!resource.isEmpty()) {
            Files.copy(HoconConfigFile.class.getResourceAsStream(resource), path);
        }
    }

    final HoconConfigurationLoader fileLoader = HoconConfigurationLoader.builder().setPath(path).build();

    return new HoconConfigFile(path, fileLoader, fileLoader.load());
}
 
开发者ID:FerusTech,项目名称:Amicus,代码行数:20,代码来源:HoconConfigFile.java

示例8: init

import java.nio.file.Files; //导入方法依赖的package包/类
void init(Path workDir) {
  if (storeDir == null) {
    storeDir = workDir.resolve("store");
    LOGGER.info(() -> "storeDir: " + storeDir.toAbsolutePath());
    try {
      Files.createDirectories(storeDir);
    } catch (IOException e) {
      throw new StorageException("Could not create storage directory: " + storeDir.toAbsolutePath());
    }
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:12,代码来源:SourceRepository.java

示例9: setup

import java.nio.file.Files; //导入方法依赖的package包/类
@BeforeTest
private void setup() throws Exception {
    Files.createDirectory(BAR_DIR);

    Path pkgDir = Paths.get("p");
    // compile classes in package p
    assertTrue(CompilerUtils.compile(SRC_DIR.resolve(pkgDir), BAR_DIR));

    // move p.Foo to a different directory
    Path foo = pkgDir.resolve("Foo.class");
    Files.createDirectories(FOO_DIR.resolve(pkgDir));
    Files.move(BAR_DIR.resolve(foo), FOO_DIR.resolve(foo),
               StandardCopyOption.REPLACE_EXISTING);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:SplitPackage.java

示例10: sourceFile

import java.nio.file.Files; //导入方法依赖的package包/类
public Builder sourceFile(String... lines) throws IOException {
    Files.createDirectories(sourceFile.getParent());
    try (BufferedWriter bw = Files.newBufferedWriter(sourceFile);
         PrintWriter writer = new PrintWriter(bw)) {
        writer.format("module %s {%n", moduleName);
        for (String l : lines) {
            writer.println(l);
        }
        writer.println("}");
    }
    return this;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ModuleInfoExtraTest.java

示例11: setup

import java.nio.file.Files; //导入方法依赖的package包/类
@BeforeTest
public void setup() throws Exception {
    boolean compiled = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
                                             MODS_DIR.resolve(TEST_MODULE));
    assertTrue(compiled, "module " + TEST_MODULE + " did not compile");

    // add the class and a resource to the current working directory
    Path file = Paths.get("jdk/test/Main.class");
    Files.createDirectories(file.getParent());
    Files.copy(MODS_DIR.resolve(TEST_MODULE).resolve(file), file);

    Path res = Paths.get("jdk/test/res.properties");
    Files.createFile(res);

    ToolProvider jartool = ToolProvider.findFirst("jar").orElseThrow(
        () -> new RuntimeException("jar tool not found")
    );

    Path jarfile = LIB_DIR.resolve("m.jar");
    Files.createDirectories(LIB_DIR);
    assertTrue(jartool.run(System.out, System.err, "cfe",
                           jarfile.toString(), TEST_MAIN,
                           file.toString()) == 0);

    Path manifest = LIB_DIR.resolve("manifest");
    try (BufferedWriter writer = Files.newBufferedWriter(manifest)) {
        writer.write("CLASS-PATH: lib/m.jar");
    }
    jarfile = LIB_DIR.resolve("m1.jar");
    assertTrue(jartool.run(System.out, System.err, "cfme",
                           jarfile.toString(), manifest.toString(), TEST_MAIN,
                           file.toString()) == 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:JavaClassPathTest.java

示例12: buildMnp

import java.nio.file.Files; //导入方法依赖的package包/类
protected MnpParser buildMnp() throws IOException {
    Path configDir = testDir.resolve("zniis");
    Path allNewNumbers = configDir.resolve(ZniisMnpParser.FILENAME_ALL);
    Files.createDirectories(allNewNumbers.getParent());
    Files.write(allNewNumbers, Arrays.asList(
            "Number,OrgName,RowCount",
            "9000000000,"+mno2.getTitle()+",13",// mts -> tele2
            "9010000000,"+mno1.getTitle(),      // tele2 -> mts
            "9000000001,"+mno2.getTitle(),      // mts -> tele2
            "9010000001,"+mno1.getTitle(),      // tele2 -> mts
            "9020000001,"+mno1.getTitle()       // beeline -> mts
    ));
    Files.write(configDir.resolve(ZniisMnpParser.FILENAME_LASTEST), Arrays.asList(
            "Number,OrgName,RowCount",
            "9000000005,"+mno3.getTitle(), //mts -> beeline
            "9010000006,"+mno1.getTitle(), //tele2 -> mts
            "9000000006,"+mno2.getTitle(), //mts -> tele2
            "9010000005,"+mno3.getTitle()  //tele2 -> beeline
    ));
    Files.write(configDir.resolve(ZniisMnpParser.FILENAME_RETURNED), Arrays.asList(
            "Number,OrgName,RowCount",
            "9000000006,mno1", // return to mts
            "9010000001,mno2", // return to tele2
            "9020000001,mno1"  // return to beeline
    ));
    return new ZniisMnpParser(configDir);
}
 
开发者ID:chukanov,项目名称:mnp,代码行数:28,代码来源:BuilderTest.java

示例13: test_moduleSourcePath_fileOnPath

import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void test_moduleSourcePath_fileOnPath(Path base) throws Exception {
    Path src = base.resolve("src");
    Path src_mA = src.resolve("mA");
    tb.writeJavaFiles(src_mA,
            "module mA { exports p; }",
            "package p; public class A { }");
    Path src_mB = src.resolve("mB");
    tb.writeJavaFiles(src_mB,
            "module mB { exports p2; }",
            "package p2; public class B { }");

    Path classes = base.resolve("classes");
    Files.createDirectories(classes);

    String log = new JavacTask(tb)
        .options("-XDrawDiagnostics=true",
                "--module-source-path", src.toString())
        .outdir(classes)
        .files(findJavaFiles(src_mB.resolve("p2")))
        .run()
        .writeAll()
        .getOutput(Task.OutputKind.DIRECT);

    showFiles(classes);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:SourcePathTest.java

示例14: setup

import java.nio.file.Files; //导入方法依赖的package包/类
private void setup(Path dest, String serviceFile) throws Exception {
    Files.createDirectories(dest);
    assertTrue(CompilerUtils.compile(SRC_DIR, dest));

    Path file = Paths.get(serviceFile.replace('/', File.separatorChar));
    Path source = SRC_DIR.resolve(file);
    Path target = CLASSES_DIR.resolve(file);
    Files.createDirectories(target.getParent());
    Files.copy(source, target);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:XMLReaderFactoryTest.java

示例15: save

import java.nio.file.Files; //导入方法依赖的package包/类
public boolean save(String name) {
	if (name == null) {
		if (mode == Consts.PVP)
			name = players[Consts.PLAYER1].getName() + "-" + players[Consts.PLAYER2].getName() + "-turn" + turn;
		else
			name = players[Consts.PLAYER1].getName() + "-AI_"
					+ (difficulty == Consts.EASY ? "EASY" : difficulty == Consts.MEDIUM ? "MEDIUM" : "HARD")
					+ "-turn" + turn;
	}

	try {
		if (!Files.isDirectory(Paths.get("Hive_init/Hive_save")))
			Files.createDirectories(Paths.get("Hive_init/Hive_save"));
		Path path = Paths.get("Hive_init/Hive_save/" + name);
		BufferedWriter writer = Files.newBufferedWriter(path);
		
		if (mode == Consts.PVAI){
                               writer.write(mode + "\n" + currentPlayer + "\n" + players[Consts.PLAYER1].getName() + "\n");
			writer.write(difficulty + "\n");
                       }
                       else if(mode == Consts.AIVP){
                               writer.write(mode + "\n" + currentPlayer + "\n" + players[Consts.PLAYER2].getName() + "\n");
			writer.write(difficulty + "\n");
                       }
                       else{
                               writer.write(mode + "\n" + currentPlayer + "\n" + players[Consts.PLAYER1].getName() + "\n");
			writer.write(players[Consts.PLAYER2].getName() + "\n");
                       }
		Stack<String> prevPlay = history.getPrevPlay();
		Stack<String> prevUnplay = history.getPrevUnplay();
		if (prevPlay.size() == prevUnplay.size())
			for (int i = 0; i < prevPlay.size(); i++)
				writer.write(prevPlay.get(i) + ";" + prevUnplay.get(i) + "\n");
		writer.flush();
                       return true;
	} catch (IOException e) {
		return false;
	}
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:40,代码来源:Core.java


注:本文中的java.nio.file.Files.createDirectories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。