當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。