本文整理匯總了Java中java.nio.file.Paths.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Paths.get方法的具體用法?Java Paths.get怎麽用?Java Paths.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.file.Paths
的用法示例。
在下文中一共展示了Paths.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveOneWithMultipartFile
import java.nio.file.Paths; //導入方法依賴的package包/類
@Test
public void saveOneWithMultipartFile() {
Picture picture = pictures.getFirst();
byte[] file = new byte[1];
file[0] = ' ';
MultipartFile multipartFile = new MockMultipartFile(picture.getName(), file);
service.save(picture, multipartFile);
assertTrue(picture.equals(service.findOne(picture.getId())));
Path f = Paths.get(picture.getPath() + picture.getName() + picture.getFileType());
if (Files.exists(f))
service.delete(picture);
else
fail("the picture wasn't created");
}
示例2: findMergePathFrom
import java.nio.file.Paths; //導入方法依賴的package包/類
private Path findMergePathFrom ( final String propertyName )
{
try
{
final String uriValue = System.getProperty ( propertyName );
if ( uriValue == null )
{
return null;
}
final Path path = Paths.get ( URI.create ( uriValue ) );
if ( path == null )
{
return null;
}
return path;
}
catch ( final Exception e )
{
logger.warn ( String.format ( "Failed to find merge URI from '%s'", propertyName ), e );
return null;
}
}
示例3: should_clone_repo
import java.nio.file.Paths; //導入方法依賴的package包/類
@Test
public void should_clone_repo() throws Throwable {
// when: clone only for plugin config file
String tmpPath = folder.getRoot().getAbsolutePath();
GitSshClient gitClient = new GitSshClient(TEST_GIT_SSH_URL, Paths.get(tmpPath));
gitClient.clone("develop", Sets.newHashSet(".flow.yml"), null);
final Set<String> acceptedFiles = Sets.newHashSet(".git", ".flow.yml", "README.md");
// then:
File[] files = gitClient.targetPath().toFile().listFiles();
Assert.assertEquals(3, files.length);
for (File file : files) {
Assert.assertTrue(acceptedFiles.contains(file.getName()));
}
}
示例4: setup
import java.nio.file.Paths; //導入方法依賴的package包/類
private static void setup() throws Exception {
Path classes = Paths.get(System.getProperty("test.classes", ""));
JarUtils.createJarFile(Paths.get("cb.jar"),
classes,
classes.resolve("Foo.class"),
classes.resolve("Foo$TestElement.class"));
}
示例5: initTaxonomyDefinitionOutputPath
import java.nio.file.Paths; //導入方法依賴的package包/類
private void initTaxonomyDefinitionOutputPath(final ApplicationArguments args) {
Path pathArg = getPathArg(args, TAXONOMY_DEFINITION_OUTPUT_PATH);
if (pathArg == null) {
pathArg = Paths.get(MIGRATOR_TEMP_DIR_PATH.toString(), HIPPO_IMPORT_DIR_DEFAULT_NAME);
}
executionParameters.setTaxonomyDefinitionOutputPath(pathArg);
}
示例6: getJavaPath
import java.nio.file.Paths; //導入方法依賴的package包/類
private Path getJavaPath(Class<?> clazz) {
final String packageDirectory = clazz.getPackage().getName().replace(".", "/");
final Path path = Paths.get("src/test/java", packageDirectory, clazz.getSimpleName() + ".java");
return path.toAbsolutePath();
}
示例7: testSetHistory
import java.nio.file.Paths; //導入方法依賴的package包/類
@Test
public void testSetHistory() throws IOException {
int LOG_HISTORY = 22;
Path CFG_PATHS = Paths.get("");
builder.setCfgPaths(CFG_PATHS);
String content = builder
.addLocLocation()
.setHistory(LOG_HISTORY)
.getContent();
builder.clearAll();
builder.readCfgFile(content);
assertTrue(builder.getHistory().compareTo(String.valueOf(LOG_HISTORY)) == 0);
}
示例8: initHippoImportDir
import java.nio.file.Paths; //導入方法依賴的package包/類
private void initHippoImportDir(final ApplicationArguments args) {
Path pathArg = getPathArg(args, HIPPO_IMPORT_DIR);
if (pathArg == null) {
pathArg = Paths.get(MIGRATOR_TEMP_DIR_PATH.toString(), HIPPO_IMPORT_DIR_DEFAULT_NAME);
}
executionParameters.setHippoImportDir(pathArg);
}
示例9: deleteFolder
import java.nio.file.Paths; //導入方法依賴的package包/類
private void deleteFolder(String tinyPounderDiskPersistenceLocation) throws IOException {
Path rootPath = Paths.get(tinyPounderDiskPersistenceLocation);
Files.walk(rootPath, FileVisitOption.FOLLOW_LINKS)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
示例10: getCustomerAttr
import java.nio.file.Paths; //導入方法依賴的package包/類
@Test
public void getCustomerAttr() throws IOException {
Path target = Paths.get("/Users/fathead/temp/file4");
UserDefinedFileAttributeView view2 = Files.getFileAttributeView(target, UserDefinedFileAttributeView.class);
ByteBuffer buf = ByteBuffer.allocate(view2.size(name));
view2.read(name, buf);
buf.flip();
String value = Charset.defaultCharset().decode(buf).toString();
System.out.println("value=" + value);
}
示例11: loadAsResource
import java.nio.file.Paths; //導入方法依賴的package包/類
public Resource loadAsResource(String path) {
Path filePath = Paths.get(properties.getUploadFileRootPath(), path);
Resource resource = new FileSystemResource(filePath.toFile());
if (resource.exists() || resource.isReadable()) {
return resource;
}
else {
throw new StorageException("Could not read file: " + path);
}
}
示例12: testCreateError
import java.nio.file.Paths; //導入方法依賴的package包/類
@Test
public void testCreateError() throws IOException {
when(langDetection.language(any(InputFile.class))).thenReturn("java");
ClientInputFile file = new TestClientInputFile(Paths.get("INVALID"), true, StandardCharsets.ISO_8859_1);
InputFileBuilder builder = new InputFileBuilder(langDetection, metadata);
exception.expect(IllegalStateException.class);
exception.expectMessage("Failed to open a stream on file");
builder.create(file);
}
示例13: isSupplementaryCharactersSupported
import java.nio.file.Paths; //導入方法依賴的package包/類
private static boolean isSupplementaryCharactersSupported() {
try {
String s = "p--\ud801\udc00--";
System.err.println("Trying: Paths.get(" + s + ")");
Path p1 = Paths.get(s);
System.err.println("Found: " + p1);
System.err.println("Trying: p1.resolve(" + s + ")");
Path p2 = p1.resolve(s);
System.err.println("Found: " + p2);
return p1.toString().equals(s) && p2.toString().equals(s + java.io.File.separator + s);
} catch (InvalidPathException e) {
System.err.println(e);
return false;
}
}
示例14: createStoreManager
import java.nio.file.Paths; //導入方法依賴的package包/類
private StoreManager createStoreManager(StoreTest storeTest, String storeName) throws Exception {
JacksonSerializer jacksonSerializer = new JacksonSerializer();
FileStoreFactory fileStoreFactory = new FileStoreFactory(Paths.get("iron_tests-" + EXECUTION_ID));
StoreManagerFactoryBuilder builder = StoreManagerFactoryBuilder.newStoreManagerBuilderFactory() //
.withSnapshotSerializer(jacksonSerializer) //
.withTransactionSerializer(jacksonSerializer) //
.withSnapshotStoreFactory(fileStoreFactory) //
.withTransactionStoreFactory(fileStoreFactory);
storeTest.configure(builder);
return builder.build().openStore(storeName);
}
示例15: main
import java.nio.file.Paths; //導入方法依賴的package包/類
public static strictfp void main(String args[]) throws Exception {
ToolBox tb = new ToolBox();
Path classPath = Paths.get(ToolBox.testClasses, "AnnotatedExtendsTest$Inner.class");
String javapOut = new JavapTask(tb)
.options("-v", "-p")
.classes(classPath.toString())
.run()
.getOutput(Task.OutputKind.DIRECT);
if (!javapOut.contains("0: #21(): CLASS_EXTENDS, type_index=65535"))
throw new AssertionError("Expected output missing: " + javapOut);
}