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