當前位置: 首頁>>代碼示例>>Java>>正文


Java Paths.get方法代碼示例

本文整理匯總了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");
}
 
開發者ID:xSzymo,項目名稱:Spring-web-shop-project,代碼行數:18,代碼來源:PicturesServiceTest.java

示例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;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:23,代碼來源:Activator.java

示例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()));
    }
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:18,代碼來源:GitSshClientTest.java

示例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"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:DeserializeButtonTest.java

示例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);
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:9,代碼來源:ExecutionConfigurator.java

示例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();
}
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:7,代碼來源:AffectedTestsDetectorTest.java

示例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);

}
 
開發者ID:ripreal,項目名稱:V8LogScanner,代碼行數:20,代碼來源:TestLogBuilder.java

示例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);
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:9,代碼來源:ExecutionConfigurator.java

示例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);
}
 
開發者ID:Terracotta-OSS,項目名稱:tinypounder,代碼行數:8,代碼來源:CacheManagerBusinessReflectionImpl.java

示例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);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:12,代碼來源:DoTestRuleFilterFactory.java

示例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);
    }
}
 
開發者ID:spring-sprout,項目名稱:osoon,代碼行數:11,代碼來源:UserFileService.java

示例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);
}
 
開發者ID:instalint-org,項目名稱:instalint,代碼行數:12,代碼來源:InputFileBuilderTest.java

示例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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Wrapper.java

示例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);
}
 
開發者ID:Axway,項目名稱:iron,代碼行數:12,代碼來源:AbstractStoreTests.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:AnnotatedExtendsTest.java


注:本文中的java.nio.file.Paths.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。