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


Java Files.createDirectory方法代码示例

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


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

示例1: nodeSettings

import java.nio.file.Files; //导入方法依赖的package包/类
@Override
protected Settings nodeSettings(int nodeOrdinal) {
    Path resolve = logDir.resolve(Integer.toString(nodeOrdinal));
    try {
        Files.createDirectory(resolve);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return Settings.builder().put(super.nodeSettings(nodeOrdinal))
        .put("discovery.type", "ec2")
        .put("path.logs", resolve)
        .put("transport.tcp.port", 0)
        .put("node.portsfile", "true")
        .put("cloud.aws.access_key", "some_access")
        .put("cloud.aws.secret_key", "some_key")
        .put(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.getKey(), "http://" + httpServer.getAddress().getHostName() + ":" +
            httpServer.getAddress().getPort())
        .build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:Ec2DiscoveryClusterFormationTests.java

示例2: init

import java.nio.file.Files; //导入方法依赖的package包/类
@PostConstruct
public void init() {
    final String os = System.getProperty("os.name");
    final String defaultDir = System.getProperty("user.home") + "/pms";

    if (os.contains("nix") || os.contains("nux") || os.indexOf("aix") > 0) {
        root = ofNullable(unixDir).orElse(defaultDir);
    } else if (os.toLowerCase().contains("win")) {
        root = ofNullable(winDir).orElse(defaultDir);
    }

    try {
        Files.createDirectory(Paths.get(root));
    } catch (IOException e) {
        log.warn("directory: \"" + root + "\" already exists!");
    }
}
 
开发者ID:akraskovski,项目名称:product-management-system,代码行数:18,代码来源:ImageService.java

示例3: testsPreparation

import java.nio.file.Files; //导入方法依赖的package包/类
void testsPreparation() throws Exception {
    Files.createDirectory(Paths.get(outDir));

    /* as an extra check let's make sure that interface 'I' can't be compiled
     * with source < 8
     */
    new JavacTask(tb)
            .outdir(outDir)
            .options("-source", source)
            .sources(ISrc)
            .run(Task.Expect.FAIL);

    //but it should compile with source >= 8
    new JavacTask(tb)
            .outdir(outDir)
            .sources(ISrc)
            .run();

    new JavacTask(tb)
            .outdir(outDir)
            .classpath(outDir)
            .options("-source", source)
            .sources(JSrc, ASrc, BSrc)
            .run();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DefaultMethodsNotVisibleForSourceLessThan8Test.java

示例4: setUp

import java.nio.file.Files; //导入方法依赖的package包/类
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:25,代码来源:ImageService.java

示例5: testNoModuleHash

import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void testNoModuleHash() throws IOException {
    Path jmod = MODS_DIR.resolve("output.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path emptyDir = Paths.get("empty");
    if (Files.exists(emptyDir))
        FileUtils.deleteFileTreeWithRetry(emptyDir);
    Files.createDirectory(emptyDir);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

    jmod("create",
         "--class-path", cp,
         "--hash-modules", ".*",
         "--module-path", emptyDir.toString(),
        jmod.toString())
        .resultChecker(r ->
            assertContains(r.output, "No hashes recorded: " +
                "no module specified for hashing depends on foo")
        );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JmodNegativeTest.java

示例6: testCryptomatorInteroperability_longNames_Tests

import java.nio.file.Files; //导入方法依赖的package包/类
/**
 * Create long file/folder with Cryptomator, read with Cyberduck
 */
@Test
public void testCryptomatorInteroperability_longNames_Tests() throws Exception {
    // create folder
    final java.nio.file.Path targetFolder = cryptoFileSystem.getPath("/", new AlphanumericRandomStringService().random());
    Files.createDirectory(targetFolder);
    // create file and write some random content
    java.nio.file.Path targetFile = targetFolder.resolve(new AlphanumericRandomStringService().random());
    final byte[] content = RandomUtils.nextBytes(20);
    Files.write(targetFile, content);

    // read with Cyberduck and compare
    final Host host = new Host(new SFTPProtocol(), "localhost", PORT_NUMBER, new Credentials("empty", "empty"));
    final SFTPSession session = new SFTPSession(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, "vault", EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()).load(session, new DisabledPasswordCallback() {
        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
            return new VaultCredentials(passphrase);
        }
    });
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    Path p = new Path(new Path(vault, targetFolder.getFileName().toString(), EnumSet.of(Path.Type.directory)), targetFile.getFileName().toString(), EnumSet.of(Path.Type.file));
    final InputStream read = new CryptoReadFeature(session, new SFTPReadFeature(session), cryptomator).read(p, new TransferStatus(), new DisabledConnectionCallback());
    final byte[] readContent = new byte[content.length];
    IOUtils.readFully(read, readContent);
    assertArrayEquals(content, readContent);
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:35,代码来源:SFTPCryptomatorInteroperabilityTest.java

示例7: setUp

import java.nio.file.Files; //导入方法依赖的package包/类
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:26,代码来源:ImageService.java

示例8: createStoreDirectory

import java.nio.file.Files; //导入方法依赖的package包/类
private void createStoreDirectory(String storeDirectory) throws IOException
{
	try
	{
		Files.createDirectory(Paths.get(storeDirectory));
	}
	catch (FileAlreadyExistsException ignore)
	{
	}
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:11,代码来源:RollUpTasksFileStore.java

示例9: main

import java.nio.file.Files; //导入方法依赖的package包/类
public static void main(String... cmdline) throws Exception {
    ToolBox tb = new ToolBox();

    // compile test.Test
    new JavacTask(tb)
            .outdir(".") // this is needed to get the classfiles in test
            .sources("package test; public class Test{}")
            .run();

    // build test.jar containing test.Test
    // we need the jars in a directory different from the working
    // directory to trigger the bug.
    Files.createDirectory(Paths.get("jars"));
    new JarTask(tb, "jars/test.jar")
            .files("test/Test.class")
            .run();

    // build second jar in jars directory using
    // an absolute path reference to the first jar
    new JarTask(tb, "jars/test2.jar")
            .classpath(new File("jars/test.jar").getAbsolutePath())
            .run();

    // this should not fail
    new JavacTask(tb)
            .outdir(".")
            .classpath("jars/test2.jar")
            .sources("import test.Test; class Test2 {}")
            .run()
            .writeAll();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:AbsolutePathTest.java

示例10: testBinConflict

import java.nio.file.Files; //导入方法依赖的package包/类
public void testBinConflict() throws Exception {
    Tuple<Path, Environment> env = createEnv(fs, temp);
    Path pluginDir = createPluginDir(temp);
    Path binDir = pluginDir.resolve("bin");
    Files.createDirectory(binDir);
    Files.createFile(binDir.resolve("somescript"));
    String pluginZip = createPlugin("elasticsearch", pluginDir);
    FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> installPlugin(pluginZip, env.v1()));
    assertTrue(e.getMessage(), e.getMessage().contains(env.v2().binFile().resolve("elasticsearch").toString()));
    assertInstallCleaned(env.v2());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:InstallPluginCommandTests.java

示例11: getBlockHistoryDir

import java.nio.file.Files; //导入方法依赖的package包/类
public Path getBlockHistoryDir() {
    Path blocksHistoryDir = Paths.get(path.toString(), "blocksHistory");
    if (!blocksHistoryDir.toFile().exists()) {
        try {
            Files.createDirectory(blocksHistoryDir);
        } catch (IOException e) {
            LOG.error(String.format("Ошибка создания директории %s: %s", blocksHistoryDir, e.getMessage()));
        }
    }
    return blocksHistoryDir;
}
 
开发者ID:technology16,项目名称:pgsqlblocks,代码行数:12,代码来源:PathBuilder.java

示例12: setUp

import java.nio.file.Files; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());

    Path test1 = Files.createDirectory(fileSystem.getPath("test1"));
    fdsMerged = new FileDataSource(test1, "ieee14bus");
    fdsUnzippedMerged = new FileDataSource(test1, "ieee14bus_ME");
    copyFile(fdsMerged, "ieee14bus_ME.xml");
    copyFile(fdsMerged, "ENTSO-E_Boundary_Set_EU_EQ.xml");
    copyFile(fdsMerged, "ENTSO-E_Boundary_Set_EU_TP.xml");

    Path test2 = Files.createDirectory(fileSystem.getPath("test2"));
    zdsMerged = new ZipFileDataSource(test2, "ieee14bus");
    copyFile(zdsMerged, "ieee14bus_ME.xml");
    copyFile(fdsMerged, "ENTSO-E_Boundary_Set_EU_EQ.xml");
    copyFile(fdsMerged, "ENTSO-E_Boundary_Set_EU_TP.xml");

    Path test3 = Files.createDirectory(fileSystem.getPath("test3"));
    fdsSplit = new FileDataSource(test3, "ieee14bus");
    fdsUnzippedSplit = new FileDataSource(test3, "ieee14bus_EQ");
    copyFile(fdsSplit, "ieee14bus_EQ.xml");
    copyFile(fdsSplit, "ieee14bus_TP.xml");
    copyFile(fdsSplit, "ieee14bus_SV.xml");
    copyFile(fdsSplit, "ENTSO-E_Boundary_Set_EU_EQ.xml");
    copyFile(fdsSplit, "ENTSO-E_Boundary_Set_EU_TP.xml");

    Path test4 = Files.createDirectory(fileSystem.getPath("test4"));
    zdsSplit = new ZipFileDataSource(test4, "ieee14bus");
    copyFile(zdsSplit, "ieee14bus_EQ.xml");
    copyFile(zdsSplit, "ieee14bus_TP.xml");
    copyFile(zdsSplit, "ieee14bus_SV.xml");
    copyFile(zdsSplit, "ENTSO-E_Boundary_Set_EU_EQ.xml");
    copyFile(zdsSplit, "ENTSO-E_Boundary_Set_EU_TP.xml");

    importer = new CIM1Importer();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:37,代码来源:CIM1ImporterTest.java

示例13: shouldNotDetectFilesInSubFolderOnStart

import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void shouldNotDetectFilesInSubFolderOnStart() throws IOException {
    Files.createDirectory(torrentsPath.resolve("sub-folder"));
    TorrentFileCreator.create(torrentsPath.resolve("sub-folder").resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
    final TorrentFileWatcher watcher = new TorrentFileWatcher(
            new FailOnTriggerListener(),
            torrentsPath,
            5
    );
    watcher.start();
    watcher.stop();
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:13,代码来源:TorrentFileWatcherTest.java

示例14: main

import java.nio.file.Files; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    Path testDir = Paths.get(System.getProperty("user.dir", "."));
    Path bootDir = Paths.get(testDir.toString(), "boot");
    Path classes = Paths.get(System.getProperty("test.classes", "build/classes"));
    Path thisClass = Paths.get(classes.toString(),
            AccessSystemLogger.class.getSimpleName()+".class");
    if (Files.notExists(bootDir)) {
        Files.createDirectory(bootDir);
    }
    Path dest = Paths.get(bootDir.toString(),
            AccessSystemLogger.class.getSimpleName()+".class");
    Files.copy(thisClass, dest, StandardCopyOption.REPLACE_EXISTING);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AccessSystemLogger.java

示例15: testJarIsDir

import java.nio.file.Files; //导入方法依赖的package包/类
public void testJarIsDir() throws IOException {
    Path imageFile = helper.createNewImageDir("test");
    Path dirJar = helper.createNewJarFile("dir");
    Files.createDirectory(dirJar);
    try {
        JImageGenerator.getJLinkTask()
                .output(imageFile)
                .addMods("dir")
                .modulePath(helper.defaultModulePath())
                .call().assertFailure("Error: Module dir not found");
    } finally {
        deleteDirectory(dirJar);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:JLinkNegativeTest.java


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