本文整理汇总了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();
}
示例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!");
}
}
示例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"));
};
}
示例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")
);
}
示例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();
}
示例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"));
};
}
示例8: createStoreDirectory
import java.nio.file.Files; //导入方法依赖的package包/类
private void createStoreDirectory(String storeDirectory) throws IOException
{
try
{
Files.createDirectory(Paths.get(storeDirectory));
}
catch (FileAlreadyExistsException ignore)
{
}
}
示例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();
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
}